Skip to content

Instantly share code, notes, and snippets.

@aetos382
Created October 17, 2017 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aetos382/ae9c13404ddd8bc2dd07953eac96793b to your computer and use it in GitHub Desktop.
Save aetos382/ae9c13404ddd8bc2dd07953eac96793b to your computer and use it in GitHub Desktop.
Jenkins.instance.getItem("projectName").items.each {
it.setDisabled(true)
try {
build = it.getLastBuild()
while (build != null) {
previousBuild = build.previousBuild
println("deleting ${build.fullDisplayName} (${build.number})")
try {
build.deleteArtifacts()
build.delete()
}
catch (Exception ex) {
println(ex)
}
build = previousBuild
}
}
finally {
it.setDisabled(false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment