Skip to content

Instantly share code, notes, and snippets.

View serbixote's full-sized avatar

Marco Davalos serbixote

View GitHub Profile
@serbixote
serbixote / builds_cleaner.groovy
Last active September 17, 2019 15:23
Delete old builds from all configured Jobs in Jenkins, in a selective way.
import jenkins.model.Jenkins
import hudson.model.Job
int MAX_BUILDS_TO_KEEP = 5
Jenkins.instance.getAllItems(Job.class).each { job ->
job.builds.drop(MAX_BUILDS_TO_KEEP).findAll {