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?
This is a feature that is given to you by Jenkins so you can change the number of builds you want to keep. If you are using a Declarative pipeline you can just add this to your code: pipeline { options { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30')) } ... }
BUILD_NUMBER is the current build number. You can use it in the command you execute for the job, or just use it in the script your job executes.
Or, you could add a snippet like this to your Pipeline/Workflow job DSL script (aka Jenkinsfile):
offset = 5
currentBuild.displayName = "#" + (currentBuild.number + offset)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With