Created
November 6, 2014 10:05
-
-
Save scrobbleme/e2cf9005e5da9f1e2b44 to your computer and use it in GitHub Desktop.
Jenkins - Remove old builds from Jenkins from all Jobs
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
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