Skip to content

Instantly share code, notes, and snippets.

@nrshrivatsan
Created April 22, 2017 02:25
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 nrshrivatsan/6eb19c56ac390fd82aee50910a8eb171 to your computer and use it in GitHub Desktop.
Save nrshrivatsan/6eb19c56ac390fd82aee50910a8eb171 to your computer and use it in GitHub Desktop.
Jenkins-delete-all-jobs : Groovyscript
import hudson.model.*
disableChildren(Hudson.instance.items)
def disableChildren(items) {
for (item in items) {
if (item.class.canonicalName == 'com.cloudbees.hudson.plugins.folder.Folder') {
disableChildren(((com.cloudbees.hudson.plugins.folder.Folder) item).getItems())
} else if (item.class.canonicalName != 'org.jenkinsci.plugins.workflow.job.WorkflowJob') {
println("Deleating job:\t"+item.name)
item.delete()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment