I have added stopping the old trigger and starting the new trigger. I have also a solution that worked without this: def jenkinsInstance = jenkins.model.Jenkins.getInstance() def SCM_TRIGGER_DESCRIPTOR = jenkinsInstance.getDescriptorOrDie(SCMTrigger. class)
def developmentView = jenkinsInstance.getView("Development") developmentView.getItems().each { project -> project.removeTrigger(SCM_TRIGGER_DESCRIPTOR) def trigger = new hudson.triggers.SCMTrigger("H/5 * * * *") trigger.job = project project.addTrigger(trigger) project.save() } mandag 21. september 2015 18.21.14 UTC+2 skrev Daniel Beck følgende: > > You forgot to `start(Job, boolean)` the trigger you added. You'll probably > also need to `stop()` any existing SCMTrigger that gets replaced by yours. > > On 21.09.2015, at 16:11, Sverre Moe <sverr...@gmail.com <javascript:>> > wrote: > > > It seems when I updated a Job configuration with Groovy in the Script > console it didn't really take effect. > > > > def jenkinsInstance = jenkins.model.Jenkins.getInstance() > > def developmentView = jenkinsInstance.getView("Development") > > developmentView.getItems().each { project -> > > def trigger = new hudson.triggers.SCMTrigger("H/5 * * * *") > > project.addTrigger(trigger) > > project.save() > > } > > > > I later checked one of my project and found it hadn't checked Git for > any changes for some time. In fact it was well over 5 minutes since last > check. I triggered a build manually and it found new changes. I went into > Configuration of that project, checked the settings and they where good SCM > trigger was set to 5 minutes. I then saved the project configuration (even > though I didn't change anything). After I did that I later checked the SCM > log and it did from that moment forward check Git every 5 minutes for > changes. > > > > So it looked like the Groovy script I executed didn't take effect, even > though it actually did update the configuration properly. > > > > Am I missing an extra step after project.save()? > > > > -- > > 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-use...@googlegroups.com <javascript:>. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/ea96dd9a-4b48-4fcf-a6b9-0f4d0dc163e4%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > -- 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/f7d92128-aa84-44aa-9461-a0cab72842bd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.