On Monday, March 2, 2015 at 11:52:29 AM UTC+1, John Carbasse wrote: > > Hello, > Is it possible, in Jenkins or by a plugin, to forbid builds for a period > (12h-14h for exemple) ? > Ideally, I look for a global parameter, I have too many jobs for set it > for each. > > Thanks for your time >
We did it with a bit of Groovy, and we're using it for only enabling our automated continuous deployments during business hours: import jenkins.model.* import hudson.model.* def jobPattern = "_Deploy_PR*" def c= new GregorianCalendar() def hour = c.get(Calendar.HOUR_OF_DAY) if ((hour >= 10) && (hour < 16)) { def matchedJobs = Jenkins.instance.items.findAll { job -> job.name =~ /$jobPattern/ } matchedJobs.each { job -> println "Enabling matching job ${job.name}" job.enable() } } else { def matchedJobs = Jenkins.instance.items.findAll { job -> job.name =~ /$jobPattern/ } matchedJobs.each { job -> println "Disabling matching job ${job.name}" job.disable() } } -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/27ab782b-1f93-42be-8a82-b7055205d567%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.