How to reset the build number in Jenkins?
To reset the build number in Jenkins you can follow this step-by-step guide. Here is the detailed description of every step to reset the build number in Jenkins:
Step 1: Log in to Jenkins Dashboard
You can simply log in to your Jenkins dashboard by using your user ID and password.
Step 2: Navigate to Manage Jenkins
After successful login you will be redirected to the Jenkins dashboard, on the left hand side you can see option of manage Jenkin, click on it.
Step 3: Script Console
Now click on the script console after that run this command:
Jenkins.instance.getItemByFullName("test-job").updateNextBuildNumber(42)
Step 4: Verify Build Number
We can verify this build number by again going to dashboard, then click on the test job and then run the job to verify it.
After that, click on the Build now
You can verify your build number
Step 5: Reset Build number in Jenkins
Now to reset the build number in Jenkins, again go the script console and then run this command:
item = Jenkins.instance.getItemByFullName("test-job")
Item.builds.each() { build -> build.delete() }
item.updateNextBuildNumber(1)
item.getNextBuildNumber()
After running command you will see result 1 means you have reset build number successfully
Step 6: Verify Reset of Build Number
After running the command successfully, you can navigate to dashboard section in this you can clearly see that there no built which clearly indicates that you have successfully reset the build number in Jenkins.
Conclusion
It must be concluded here that you can successfully reset build number in Jenkin by simply following the mentioned steps of the article. You must remember all the prerequisite before resetting the build number in Jenkins.
How To Reset Build Number In Jenkins?
Jenkins is an open-source automation server that is mainly used in building, testing, and deploying software projects. In some scenarios, you must have found yourself in a situation where you want to reset the build number in Jenkins. Whether it is because of organizational reasons, or you want to start new, or any other specific reason. You can reset the build number in Jenkins by following the mentioned steps in the article and also we will going to discuss it in detail.