Skip to content

Instantly share code, notes, and snippets.

@scrobbleme
Created November 6, 2014 10:05
Show Gist options
  • Save scrobbleme/e2cf9005e5da9f1e2b44 to your computer and use it in GitHub Desktop.
Save scrobbleme/e2cf9005e5da9f1e2b44 to your computer and use it in GitHub Desktop.
Jenkins - Remove old builds from Jenkins from all Jobs
for(item in Jenkins.instance.items) {
println("Deleting builds of job "+item.name)
counter = 1
for(build in item.getBuilds()){
if(counter > 5){
println("Delete " + build.number)
try{
build.delete()
}catch(Exception e){
println(e.getMessage())
}
}else{
println("Skip " + build.number)
}
counter++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment