Skip to content

Instantly share code, notes, and snippets.

@bhaku
Forked from nextrevision/deleteJenkinsJobs.groovy
Created December 29, 2016 10:16
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 bhaku/c49b25ec8f0087f86a1031cd6067178f to your computer and use it in GitHub Desktop.
Save bhaku/c49b25ec8f0087f86a1031cd6067178f to your computer and use it in GitHub Desktop.
Groovy script to delete all jenkins jobs that match a regex pattern
import jenkins.model.*
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /my_regex_here/
}
matchedJobs.each { job ->
println job.name
//job.delete()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment