I am migrating jenkins-workflow job to new template based workflow job. Because the build number is used as part of the version of build artifacts the workflow produces I have to start build number of the new workflow with a number greater than the old workflow. Unfortunately 'Next Build Number' plugin does not work with workflow pipeline.
Anybody knows a good way do this?
I also found another way of doing this by using 'jenkins-cli'. It works for locked down installations where access to script console is not available (Cloudbees Enterprise Jenkins)
Unfortunately the methods listed above didn't work for me when using folders. I resorted to the following in the Jenkins script console:
Try running below script in Jenkins Script Console.. Change "workFlow" to your Jobname
A few notes:
@NonCPS
Jenkins.instance
are not accessible otherwiseJenkins.instance.getItem()
won't work well with folders. UseJenkins.instance.getItemByFullName
against theenv.JOB_NAME
job.nextBuildNumber
will take effect subsequent build, so go ahead and kick off the next oneCode:
Or, you could add a snippet like this to your Pipeline/Workflow job DSL script (aka Jenkinsfile):