Skip to content

Instantly share code, notes, and snippets.

@epishan
Forked from sergey-epishkin-lzd/delete_job.groovy
Last active June 12, 2017 13:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epishan/0ab7a2459a06f2092635c5f2b7a8a8ac to your computer and use it in GitHub Desktop.
Save epishan/0ab7a2459a06f2092635c5f2b7a8a8ac to your computer and use it in GitHub Desktop.
[jenlins] Jenkins jobs cleanup
// Groovy script to disable job in Hudson
import hudson.model.*;
def JOB_PATTERN = ~/^GO.*.deploy*.staging2$/; //find all jobs starting with "MY_JOB".
(Hudson.instance.items.findAll { job -> job.name =~ JOB_PATTERN }).each { job_to_update ->
if (job_to_update.name =~ "^\$") {
return;
}
else {
println ("Updating job " + job_to_update.name);
job_to_update.disable()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment