-
Bug
-
Resolution: Fixed
-
Major
I am attempting to calculate a value to be used in a few different places in my pipeline. The definition is in a method (in a global library, but I have identical behavior with an inline method).
environment { MY_VAR = calculate() }
In this scenario, MY_VAR is always null--even if the RHS is the GString {{ "${1+2}" }}! In fact, credentials() is the only non-compile-time-constant expression that I can get to evaluate to non-null.
I expected the values in the environment block to be evaluated on the master when the pipeline is started up and then injected appropriately.
- links to
So this should work fine with a global library (not a library loaded via @Library or the libraries directive, though) - see https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/master/pipeline-model-definition/src/test/resources/nonLiteralEnvironment.groovy for an example (returnAThing(...) is defined in the global library). This should get reworked for @Library and libraries to work, but an inline method I wouldn't expect to ever work.