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

17 views
Skip to first unread message

Michael Carter

unread,
Nov 29, 2020, 10:36:50 PM11/29/20
to Jenkins Developers
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?

Jesse Glick

unread,
Nov 30, 2020, 5:03:36 PM11/30/20
to Jenkins Dev
On Sun, Nov 29, 2020 at 10:36 PM Michael Carter
<mikeyca...@gmail.com> 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?
Reply all
Reply to author
Forward
0 new messages