Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use project source retriever #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ apply plugin: 'groovy'

repositories {
mavenCentral()
maven { url 'https://repo.jenkins-ci.org/releases/' }
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.6'
testCompile 'junit:junit:4.12'
testCompile files('C:\\Users\\jim\\Code\\JenkinsPipelineUnit\\build\\libs\\jenkins-pipeline-unit-1.2-SNAPSHOT.jar')
testCompile group:'com.lesfurets', name:'jenkins-pipeline-unit', version:'1.2'
testCompile 'commons-io:commons-io:2.5'
testCompile 'com.cloudbees:groovy-cps:1.12'
testCompile 'org.slf4j:slf4j-simple:1.7.25'
Expand Down
26 changes: 11 additions & 15 deletions test/com/example/TestCase1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,30 @@ import org.junit.Test

import com.lesfurets.jenkins.unit.BasePipelineTest
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.LocalSource.localSource
import static com.lesfurets.jenkins.unit.global.lib.ProjectSource.projectSource

class TestCase1 extends BasePipelineTest {

@Override
@Before
void setUp() throws Exception {
// TODO: Find a better way of getting project root dir
String dirPath = new File( System.getProperty("user.dir") )
.getAbsoluteFile()
.getParentFile()
.getAbsolutePath()

def library = library()
.name('jenkinslib-example')
.allowOverride(true)
.implicit(false)
.targetPath(dirPath)
.retriever(localSource(dirPath))
.build()

def library = library()
.name('jenkinslib-example')
.defaultVersion('<notNeeded>')
.allowOverride(true)
.implicit(false)
.targetPath('<notNeeded>')
.retriever(projectSource())
.build()
helper.registerSharedLibrary(library)

super.setUp()
}

@Test
void should_run_example_pipeline_without_errors() throws Exception {
def script = loadScript("test\\resources\\pipelines\\example1.pipeline")
def script = loadScript("test/resources/pipelines/example1.pipeline")
script.execute()
printCallStack()
}
Expand Down