groovy scripts for Jenkins
At some point, if you are working on managing Jenkins for your team, you will find yourself looking for a set of useful groovy scripts to control jenkins configuration for a large no of builds/jobs. Following are some mostly frequently needed ones Get all jobs that belong to a view hudson.model.Hudson.instance.getView('my-view')?.items.each() { println it.fullDisplayName } Clear the build queue import hudson.model.* def queue = Hudson.instance.queue println "Queue contains ${queue.items.length} items" queue.clear() println "Queue cleared" Disable jobs in a view hudson.model.Hudson.instance.getView('1.1.x-tests')?.items.each() { println("JOB : "+it.name) it.disabled=true it.save() } Get all jobs that that define a TimerTrigger with the trigger spec import hudson.model.* import hudson.triggers.* for(item in Hudson.instance.items) { for(trigger in item.triggers.values()) { if(trig...