On Mon, Jul 12, 2021 at 11:50 AM Gregory Paciga <[email protected]>
wrote:

> If both listeners have access to the same node, I feel there must be some
> way of getting the same information.


`GraphListener` has the `FlowNode` as it is being added (but no runtime
details about the *program*) whereas `StepListener` has the information
about the step that the program is about to run (but before it has added to
the graph). So they are complementary. In your case it looks like you just
need to implement both and pass information from one to the other, keyed by
node id. It would be helpful to have some richer listener interface that
offers both kinds of information at once, but currently there is no such
API.

if there's not a way of getting at that information from the flownode
> itself (and I'd still really like to know *why* that is the case)
>

The `FlowNode` survives past the end of the build (currently as a set of
XML files) and is just a record of what the structure of the build was,
including any persisted `Action`s. The live objects that were originally
passed around in the program, saved to `program.dat` and including anything
present in `StepContext` for the dynamic scope of a block, are not retained.

Anyway, back to your original question,
https://javadoc.jenkins.io/plugin/workflow-api/org/jenkinsci/plugins/workflow/actions/WorkspaceAction.html#getNode--
ought to tell you the name of the agent running a `node` block, or the
empty string in the case of a controller executor (typically ill-advised).
*While* the `node` block is running, you can look up the actual `Node`
based on that name. (After the block exits, this is no longer valid; for
example, when using the `kubernetes` plugin, the agent will have been
immediately discarded.)

-- 
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/CANfRfr2d843DRPTKg1CRzixYE%3DGNYwmDH8d3QSKGVQWM2UHMDA%40mail.gmail.com.

Reply via email to