Skip to content

Instantly share code, notes, and snippets.

@imander
Created January 26, 2021 22:23
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 imander/219c1f1e46aa7b750ec02d1b639ba8ce to your computer and use it in GitHub Desktop.
Save imander/219c1f1e46aa7b750ec02d1b639ba8ce to your computer and use it in GitHub Desktop.
Delete all failed Jenkins Jobs
def jobnames = Jenkins.instance.getJobNames()
jobnames.each {
println("Checking Job: ${it}");
def job = Jenkins.instance.getItemByFullName(it)
job.getBuilds().each {
if (it.result == Result.FAILURE) {
// Delete failed job
it.delete()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment