Skip to content

Instantly share code, notes, and snippets.

@tizki
Last active November 19, 2015 13:20
Show Gist options
  • Save tizki/10ebf8453c4247993be1 to your computer and use it in GitHub Desktop.
Save tizki/10ebf8453c4247993be1 to your computer and use it in GitHub Desktop.
Jenkins groovy script - bulk disable non-disabled jobs by name
def jobToDisable = "MyJob1&MyJob2&MyJob3"
def j = Jenkins.getInstance()
jobs = jobToDisable.split("&")
//println("I: ${jobs}")
jobs.each{ jobName ->
try{
def job = j.getItem(jobName)
println(" ${jobName}: ${job.isDisabled()}")
if(job.isDisabled().equals(false)){
job.disable()
}
}
catch(Exception e){
println("WARNING: ${jobName}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment