Thanks for that suggestion, that did let me make some progress by getting 
access to the StepContext (from which I can get the Computer), but 
unfortunately that creates other problems. In particular, information which 
is available in a FlowNode doesn't seem available from the Step.

I can do context.get(FlowNode.class), but some information is still 
missing, e.g. for a "stage" Step, the FlowNode (a StepStartNode) doesn't 
yet have a LabelAction associated with it. If I get the same StepStartNode 
from my GraphListener (or at least what I think is the same - a 
StepStartNode associated with the beginning of a new stage), I can use the 
LabelAction to get the stage name.

I also have the problem that I need to use both StepStartNode and the 
StepEndNode, so I can get information like the step duration, which 
GraphListener does provide. That doesn't seem to be possible with a 
StepListener, which only sees the start of each step. While I would prefer 
to be able to get the Computer at both the start and end (to make it easier 
to do things like correlate a specific Computer with error messages at the 
end of the stage), I could compromise by using StepListener to get the 
start of a step and GraphListener to get the end of it, but only if the 
stage name can be found.

Given the FlowNode from GraphListener, is there a way to get to the 
StepContext?

On Thursday, July 8, 2021 at 5:57:42 PM UTC-4 Jesse Glick wrote:

> On Thu, Jul 8, 2021 at 12:48 PM Gregory Paciga <[email protected]> wrote:
>
>> I'm working on a Jenkins plugin that 
>> implements org.jenkinsci.plugins.workflow.flow.GraphListener to monitor how 
>> a pipeline is progressing. It 
>> receives org.jenkinsci.plugins.workflow.graph.FlowNode objects. I would 
>> like to be able to report on which agent a particular FlowNode is running 
>> on.
>>
> Try 
> https://javadoc.jenkins.io/plugin/workflow-api/org/jenkinsci/plugins/workflow/flow/StepListener.html#notifyOfNewStep-org.jenkinsci.plugins.workflow.steps.Step-org.jenkinsci.plugins.workflow.steps.StepContext-
>  
> instead. 
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/b954ccf6-ebf7-48eb-a213-91448a1a6f8cn%40googlegroups.com.

Reply via email to