Created
February 28, 2020 16:41
-
-
Save uurtech/fdf5956f776de6c938d46da880f9f151 to your computer and use it in GitHub Desktop.
Delete Old Builds Jenkins Script
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
//you can go to Manage Jenkins > Script Console | |
import jenkins.model.Jenkins | |
import hudson.model.Job | |
MAX_BUILDS = 55 | |
Jenkins.instance.getAllItems(Job.class).each { job -> | |
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