pipelineUnit icon indicating copy to clipboard operation
pipelineUnit copied to clipboard

When the Jenkinsfile is renamed and the path in the test is adjusted the test fails

Open 030 opened this issue 8 years ago • 1 comments

When Jenkinsfile was renamed, e.g. x.jenkins and the path in the test as well, the gradle build fails:

when cloned:

gradle clean build

BUILD SUCCESSFUL in 8s
4 actionable tasks: 4 executed

when Jenkinsfile renamed

gradle clean build

> Task :test 

tests.job.JenkinsfileTestSpec > Jenkinsfile should run gradle tests with expected command line validate:null gradle: null FAILED
    groovy.util.ResourceException at JenkinsfileTestSpec.groovy:26
        Caused by: groovy.util.ResourceException at JenkinsfileTestSpec.groovy:26

Then I thought perhaps there is another jenkins file. This was the case, i.e. ./exampleJobs/parallel/Jenkinsfile and when this was renamed the issue persisted.

Should all Jenkins. entries that reside in the test files be renamed as well?

030 avatar Dec 01 '17 22:12 030

If you rename the Jenkinsfile at the top level say to something like "Foo.groovy" you will need to look for the lines in the tests like "runScript('Jenkinsfile')" and change to "runScript('Foo.groovy')". Also, for tests that assert the pipeline call stacks to a file using 'testNonRegression', the content of all these call stack files will need updating for lines like 'Jenkinsfile.pipeline(groovy.lang.Closure)' which would become 'Foo.pipeline(groovy.lang.Closure)' (these are the files under 'tests/callstacks'. You don't need to update these call stack files manually though, you can go into the gradle.properties file and set 'pipeline.stack.write=true' then run all the tests and review the changes. Does this answer it?

macg33zr avatar Aug 30 '18 22:08 macg33zr