Skip to content

Instantly share code, notes, and snippets.

@evbruno
Created April 21, 2020 21:04
Show Gist options
  • Save evbruno/a0f07f4a976e2259da04090f1e662d05 to your computer and use it in GitHub Desktop.
Save evbruno/a0f07f4a976e2259da04090f1e662d05 to your computer and use it in GitHub Desktop.
Delete Jenkins builds
def subject = "job name"
Jenkins.instance.getAllItems(Job.class).each { job ->
if (job.toString().contains(subject)) {
println " > " + job.name
job.builds.each { build ->
println ' >> ' + build.number + ' > ' + build.result + ' > ' + build.getDescription()
//
//if (build.number < 100) build.delete()
//if (Result.SUCCESS != build.result) build.delete()
}
job.nextBuildNumber = 1
job.save()
}
}
subject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment