Wednesday, January 3, 2018
How to clean and reset Jenkins build history
How to clean and reset Jenkins build history
When you working with Jenkins while building your solution, definitely you have to run your project multiple times. It will result to a long Build History list that looks ugly and unnecessary for your production environment.

1. Go to `Jenkins Script Console`
Go to your Jenkins home page > Manage Jenkins > Script Console

2. Run the script to clean and reset
Copy and paste this script to your Console Script text area and change the "copy_folder" to project name that you need to clean the history. Then click the "Run button".
def jobName = "copy_folder"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()
Now check your Build History for the particular project, Wow!, its clean now!