How do I get the Run/Job of a TimerTrigger?

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

How do I get the Run/Job of a TimerTrigger?

Michael Carter
So what I'm doing.  Trying to make a SimpleParameterDefinition persistent by looking up the previous success full build and using it's parameters as the default for the timer triggered job.

hudson.triggers.Trigger#checkTriggers: hudson.triggers.TimerTrigger.run() failed for org.jenkinsci.plugins.workflow.job.WorkflowJob@7acbb62c

So Stapler.getCurrentRequest().findAncestorObject(Job.class); doesn't work inside the getDefaultParameterValue

How do I get at the Job definition here?

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" 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-dev/670387dd-1307-4428-91ad-e59f2bb258dan%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the Run/Job of a TimerTrigger?

Jesse Glick-4
On Sun, Nov 29, 2020 at 10:36 PM Michael Carter
<[hidden email]> wrote:
> So Stapler.getCurrentRequest().findAncestorObject(Job.class); doesn't work inside the getDefaultParameterValue

No, because there is no HTTP request here. I do not think
`ParameterDefinition.getDefaultParameterValue` has any way of
determining which `Job` it is associated with (if indeed there is a
single unique answer).

Maybe you should revisit your design. Use a stock
`ParameterDefinition` type, but have a `RunListener` update its
default value after a build passes?

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" 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-dev/CANfRfr3Xcn%3D-cZ4FWQz4pYu1Dc47G%2BGdE%2BG_87GDwXTDzNh_mQ%40mail.gmail.com.