Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset build number in jenkins?

Tags:

jenkins

I am using Jenkins and Gradle to build my java project.

Every time I build my project, I get a new build number on the Jenkins screen.

The following is my Jenkins build info:

Success > Console Output  #96   03-Jan-2014 15:35:08     Success > Console Output  #95   03-Jan-2014 15:27:29      Failed > Console Output  #94    03-Jan-2014 15:26:16      Failed > Console Output  #93    03-Jan-2014 15:25:01      Failed > Console Output  #92    03-Jan-2014 15:23:50      Success > Console Output  #91   03-Jan-2014 12:42:32     Success > Console Output  #90   03-Jan-2014 12:02:45 

I want to reset the Jenkins build number like:

Success > Console Output  #1    03-Jan-2014 12:02:45 

How can I reset the build number in Jenkins?

like image 267
Sivakumar M Avatar asked Jan 03 '14 10:01

Sivakumar M


People also ask

How do I remove old builds in Jenkins?

Delete a Jenkins build via GUI. Go into the build you want to delete, and click the Delete this build button in the upper right corner. If you need to clean the Jenkins build history, and reset the build number back to 1, you can run a simple script in Jenkins Script Console.

How do I fix Jenkins build?

The user needs to open the console output for the build and will try to see if any file changes that were missed during building the project. If there aren't any problems on it then a much better approach would be clean and update his local workspace to copy the problem on their local machine and will try to solve it.


1 Answers

Can be easier done from groovy script console . Go to http://your-jenkins-server/script In script window enter:

item = Jenkins.instance.getItemByFullName("your-job-name-here") //THIS WILL REMOVE ALL BUILD HISTORY item.builds.each() { build ->   build.delete() } item.updateNextBuildNumber(1) 
like image 164
antweiss Avatar answered Sep 20 '22 11:09

antweiss