jobs modified via script console do not take effect

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

jobs modified via script console do not take effect

Arturo Flores
I used a script similar to this one to modify a job via the script console (http://[my_jenkins_url]/script ):

import hudson.triggers.*

midnightTrigger = new TimerTrigger("* * * * *")

job = Jenkins.instance.getItem("some jenkins job")
job.addTrigger( midnightTrigger )

for( trigger in vortexJob.triggers.values() ) {
  println( trigger )
  println( trigger.spec )
}

job.save()


For the sake of this example, I set it to run every minute.  The output is as expected:
hudson.triggers.TimerTrigger@7890613d
* * * * *

However, the job does not run every minute.  If I view the job via the web interface, I see that the job is scheduled to run every minute, but it simply does not run.  If I save using the web interface, then the job does run every minute.

Any idea why?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0a6381af-1c59-41d6-ab13-a677177cb2aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

AW: jobs modified via script console do not take effect

Reinhold Fuereder

Hi Arturo,

 

maybe this answer by Andrew on Saturday, 23 September 2017 03:01:26 UTC+5:30 explains it:

Yeah, the job has to run at least once after you've added the triggers directive for it to register, and then it'll be fine.

 

Please see https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/jenkinsci-users/wI0lzVSjmFg/dUPberPmAQAJ for more details...

 

HTH Reinhold

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/C3D41C0B1D5991438F1A43F586F4B47F8169C0DF%40TIGER2010.xortex.local.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jobs modified via script console do not take effect

Arturo Flores
It doesn't seem that was the answer.

So I modified the script by adding:

job.scheduleBuild(0)

at the end to trigger a build.  I observed the job build in the web interface.  However, the job did not build every minute after this.  I also triggered a build by clicking the "Build Now" link in the web interface.  Even after this, the job does not build every minute as scheduled.  However, if I click save on the web interface at http://[my jenkins url/[some jenkins job]/configure , then the job starts building every minute.  I did not make any changes in the web interface job configuration page, I simply pulled up the page and clicked save.

Does this sound like a bug?  I have several dozen jobs for which I want to change the build triggers.  I am hoping to be able to do this via the script console and not have to do it manually.


On Tuesday, October 24, 2017 at 10:52:21 PM UTC-7, Reinhold Fuereder wrote:

Hi Arturo,

 

maybe this answer by Andrew on Saturday, 23 September 2017 03:01:26 UTC+5:30 explains it:

Yeah, the job has to run at least once after you've added the triggers directive for it to register, and then it'll be fine.

 

Please see <a href="https://groups.google.com/forum/?utm_medium=email&amp;utm_source=footer#!msg/jenkinsci-users/wI0lzVSjmFg/dUPberPmAQAJ" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/forum/?utm_medium\x3demail\x26utm_source\x3dfooter#!msg/jenkinsci-users/wI0lzVSjmFg/dUPberPmAQAJ&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/forum/?utm_medium\x3demail\x26utm_source\x3dfooter#!msg/jenkinsci-users/wI0lzVSjmFg/dUPberPmAQAJ&#39;;return true;"> https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/jenkinsci-users/wI0lzVSjmFg/dUPberPmAQAJ for more details...

 

HTH Reinhold

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1436e5d2-1523-4e3a-88b3-c8de4f668fe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.