Last active
August 29, 2015 14:16
-
-
Save kneradovsky/1eaebc1cbc0122f24828 to your computer and use it in GitHub Desktop.
clean up old build in 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
def jenkins=Jenkins.instance | |
def jobs=jenkins.getItems(Job.class) | |
long monthAgo=System.currentTimeMillis()-((long)3600*24*30)*1000 | |
println monthAgo | |
jobs.each { Job job -> | |
job.builds.each { build -> | |
if(build.startTimeInMillis<monthAgo) { | |
build.delete() | |
println job.displayName+":"+build.displayName | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Deletes all builds older than one month (30 days) of all jobs in jenkins