Created
September 21, 2015 11:24
-
-
Save jarek-przygodzki/cc8a2f765d9cbee30f7a to your computer and use it in GitHub Desktop.
Delete Jenkins build history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// change this variable to match the name of the job whose builds you want to delete | |
def jobName = "Your Job Name" | |
def job = Jenkins.instance.getItem(jobName) | |
job.getBuilds().each { it.delete() } | |
// reset the build number to 1 | |
job.nextBuildNumber = 1 | |
job.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def myjobs= [
'task_1':36,
'task_2':7,
'task_3':7,
'task_4':7
]
for (myjob in myjobs) {
Jenkins.instance.getItemByFullName(myjob.key).builds.findAll {
it.number <= myjob .value
}.each {
it.delete()
}
}