Updating TimerTriggers using Groovy script stops job from triggering

XMLWordPrintable

    • Type: Bug
    • Resolution: Incomplete
    • Priority: Major
    • Component/s: groovy-plugin
    • None
    • Environment:
      any

      I am trying to update the TimerTriggers for several jobs using a Groovy system script, and although the timertrigger specs appear to change, the actual build is never triggered from then on.

      import hudson.model.*
      import hudson.triggers.*
      
      
      int hourMax = 23 // could be 8, for 8am, before everyone comes in... 
      int minMax = 59
      int incr = 15
      int hr = 0
      int m = 0
      
      
      for(item in Hudson.instance.items) {
          item.triggers.each{ descriptor, trigger ->
              if(trigger instanceof TimerTrigger) {
                  println("--- Timer trigger for " + item.name + " ---")
                  println(trigger.spec + '\n')
                  if(item.name != "merge-process"){
                      item.removeTrigger descriptor
                      item.save()
                      item.addTrigger(new TimerTrigger("$m $hr * * *"))
                      item.save()
                      println "updated to $m $hr * * *"
                      m += incr
                  }
                             
                  
                  if(m > minMax){ hr++; m = 0}
                  if(hr > hourMax) { hr = 0; }
              }
          }
      }
      

      I also tried to disable the general timer first:

      Trigger.timer.cancel()
      

      .. but it still fails to trigger the timer.

      Is this a bug, or am I doing something wrong?

            Assignee:
            vjuranek
            Reporter:
            matt203895
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: