You can use either nexBuildNumber plug-in or simply modify nexBuildNumber file to reset build number. Following are the steps that you need to perform: Go to . jenkins/Jobs/<YourJobName>/build/ , take backup of this folder(if you need for future use) and delete build folder.
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. See the Jenkins documentation for the full list of available environment variables.
Navigate to the Jenkins dashboard and select Build History. This timeline displays your build history. This table displays a list of your past builds, time since build and the status of each build.
If you have access to the script console (Manage Jenkins -> Script Console), then you can do this following:
Jenkins.instance.getItemByFullName("YourJobName").updateNextBuildNumber(45)
can be done with the plugin: https://wiki.jenkins-ci.org/display/JENKINS/Next+Build+Number+Plugin
more info: http://www.alexlea.me/2010/10/howto-set-hudson-next-build-number.html
if you don't like the plugin:
If you want to change build number via nextBuildNumber file you should "Reload Configuration from Disk" from "Manage Jenkins" page.
Under the job workspace folder, like:
C:\Program Files (x86)\Jenkins\jobs\job_name
there is a file named nextBuildNumber
.
Setting the build number in the file and reloading the configuration from disk (Manage Jenkins menu) will force the next build you start to have the value from the file as BUILD_NUMBER.
If you have branch name including Forward Slash (using git flow for example), you will need to replace the Forward Slash with its Unicode character %2F within the branch name.
Here is an example for the pipeline My-Pipeline-Name and the branch release/my-release-branch-name
Jenkins.instance.getItemByFullName("My-Pipeline-Name/release%2Fmy-release-branch-name").updateNextBuildNumber(BUILD_NUMBER)
I was able to find out about this by running the following command which will list the different jobs (branches) for your pipeline
Jenkins.instance.getItem("My-Pipeline-Name").getAllJobs()
Hope it helps.
Perhaps a combination of these plugins may come in handy:
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