Hi,
I'm trying to use the EnvInject plugin. Specifically in the "Prepare an
environment for the run" > "Evaluated Groovy script" I want to be able to
get access to the job's BUILD_NUMBER so that I can inject a variable that
is partly composed of that value.
I've tried code like:
def manager = binding.getVariable("manager")
def buildNumber =
manager.build.getEnvironment(manager.listener)['BUILD_NUMBER']
But I get an error of:
[EnvInject] - [ERROR] - SEVERE ERROR occurs: No such property: manager for
class: groovy.lang.Binding
I've tried code like:
def buildNumber =
manager.build.getEnvironment(manager.listener)['BUILD_NUMBER']
But I get an error of:
[EnvInject] - [ERROR] - SEVERE ERROR occurs: No such property: manager for
class: Script1
Is the manager - via any API call - available at the time that script runs?
The following code works (and it returns the correct value), but i'm just
trying to avoid having the Job's name (i.e. - "BnL Build") be hard-coded in
the script:
def env = Jenkins.instance.getItem("BnL
Build").getLastBuild().getEnvironment()
def buildNumber = env['BUILD_NUMBER']
Thanks in advance,
Matt