Skip to content

Instantly share code, notes, and snippets.

@kneradovsky
Last active August 29, 2015 14:16
Show Gist options
  • Save kneradovsky/1eaebc1cbc0122f24828 to your computer and use it in GitHub Desktop.
Save kneradovsky/1eaebc1cbc0122f24828 to your computer and use it in GitHub Desktop.
clean up old build in Jenkins.
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
}
}
}
@kneradovsky
Copy link
Author

Deletes all builds older than one month (30 days) of all jobs in jenkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment