Wednesday, September 25, 2019

How to clear jenkins history


In the script console,
Run this script to clean and reset.
Copy and paste this script to your Console Script text area and change the "copy_folder" to the 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()
If you're using multibranch pipeline or folders, the second line of the script above has to be modified like this:
def jobName = "path/to/your/jenkins/pipeline/master"
def job = Jenkins.getInstance().getItemByFullName(jobName, Job.class)

Reference

No comments:

Post a Comment