Is there a way to modify the value of an environment variable for a single
step
or block in Pipeline from a GraphListener?
The value would have to change for each node. (For the background read on)
So far I have tried to add a custom EnvironmentContributingAction in
GraphListener.onNewHead(). But those actions seem to be only evaluated
before
each build in AbstractBuild.getEnvironment().
I also tried EnvActionImpl.forRun((Run)
flowNode.getExection().getOwner().getExecutable())
in GraphListener.onNewHead() which only changes it for the *next* step, as
apparently the StepContext has already been set up.
(It is probably also not great in case of parallel jobs)
EnvironmentContributor is also documented to affect the whole build.
The best way forward seems to somehow get hold of the StepContext from
GraphListener.onNewHead() but so far I could not find a way to do so.
I would be grateful for any pointers.
Background:
I am trying to integrate an OpenTracing [0] tracer into Jenkins.
It will record executions for all Pipeline runs / queueing processes etc...
The tracing inside Jenkins works (mostly) fine so far.
Now the issue is to propagate the tracing context from within Jenkins to the
executed steps. in this case Maven for which a similar plugin was created.
The probably best way of propagating this information is via environment
variables.
Obviously the value of this environment variable will have to change often
during the course of a single build.
It would also be nice if the plugin could work without any changes to the
Pipeline definition itself.
(It is planned to add optional custom steps/methods)
PS: it seems the usage of env vars with a dash ("-") in their keys is
broken.
Even when set directly via the Java APIs, they don't show up in the "sh"
pipeline step.
Thanks,
Thomas
[0] http://opentracing.io/
--
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/0da82c0f-c885-4093-9469-6abb9bb134c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.