Created
April 22, 2016 20:38
-
-
Save marcotc/5a5290f311909be7e14f1c12a23eca97 to your computer and use it in GitHub Desktop.
Delete builds older then N on Jenkins
This file contains 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
MAX_BUILDS = 10 | |
for (job in Jenkins.instance.items) { | |
println job.name | |
def recent = job.builds.limit(MAX_BUILDS) | |
for (build in job.builds) { | |
if (!recent.contains(build)) { | |
println "Preparing to delete: " + build | |
// build.delete() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment