We run groovy script to remove timer trigger or other triggers, sample code
import hudson.model.*
import hudson.triggers.*
import jenkins.model.*
import com.cloudbees.hudson.plugins.folder.Folder

def TIMER_TRIGGER_DESCRIPTOR = 
Hudson.instance.getDescriptorOrDie(TimerTrigger.class)

def removeTrigger
removeTrigger={ it ->
    if (it==null || it?.name=='the preserved job'){
      return
    }
    if(it instanceof Folder){
      for(subitem in it.items){
        removeTrigger(subitem)
      }
      return
    }

    def timertrigger = it.getTriggers().get(TIMER_TRIGGER_DESCRIPTOR)
    if(timertrigger != null){  println("remove Trigger for "+  it.url);
        it.removeTrigger(TIMER_TRIGGER_DESCRIPTOR)
    }
}

def name=build.buildVariables.name.replace('/job/','')
println "will remove timer from ${name}"
removeTrigger(Jenkins.instance.getItem(name,(ItemGroup)null))





On Monday, November 7, 2016 at 10:04:51 PM UTC+8, Michael Giroux wrote:
>
> We have a large jenkins configuration with 1700 jobs.  We have two use 
> cases in which the configuration is copied. We make a copy of the 
> configuration prior to any upgrade:
>
> 1. for purposes of testing new version and plugins prior to an upgrade
> 2. to have a running instance of the previous version to allow "emergency 
> builds" for projects that will not build in new version after an upgrade.
>
> In both of these use cases, we have two copies of Jenkins running at the 
> same time (on different ports of course), the old version, and the new 
> version.  In either case, we want to disable the build triggers for one of 
> the instances.  We do not want two copies of jenkins building the same 
> project based on polling, or due to upstream builds and/or snapshot changes.
>
> We can use "prepare to shutdown" to suspend one instance.  But if we 
> cancel shutdown to allow a specific build to be run, the flood gates open.
>
> It would be helpful  if there was an option to allow manual builds even 
> when "prepare to shutdown" is in effect.  Or, as the subject line suggests, 
> an option to disable triggers. Such an option should have an initial state 
> set by a system property allowing us to launch Jenkins with the option 
> initially on or off.
>
> Similar requests have been made previously:
> http://jenkins-ci.361315.n4.nabble.com/Suspend-Plugin-td1599530.html
>
> http://stackoverflow.com/questions/1299180/can-i-disable-hudsons-automatic-scheduled-builds-all-at-once
>
> I would be interested in hearing how other users handle this case, 
> especially case #2 in which we wish to have the old instance of Jenkins 
> available to run builds that might not execute in the new version.
>
> Michael
>
>
>

-- 
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/9361c5e5-9c30-45fd-9392-6d714a39d024%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to