The current method using EnvInject can't work within a declarative Pipeline (statement from CloudBees support), and possibly not even within a scripted Pipeline, as we couldn't get it to run, even with support. Additionally the EnvInject Plug-In is out of maintainer and generates exceptions in Jenkins, so it should be (IMHO) avoided.
The current method using EnvInject can't work within a declarative Pipeline (statement from CloudBees support), and possibly not even within a scripted Pipeline, as we couldn't get it to run, even with support. Additionally the EnvInject Plug-In is out of maintainer and generates exceptions in Jenkins, so it should be (IMHO) avoided.
Workaround in the meantime has been adapted from https://github.com/automaticdavid/jenjen/blob/master/Jenkinsfile and looks as follows for a simple Pipeline (the link is for multibranch pipeline):
The workaround worked for us when sending the vars back using the set_stats approach, but not when using the debug/msg/JENKINS_EXPORT method.