Wow, talk about service. Thanks a lot for adding that ... I'm using it
already and loving it.
On Friday, December 21, 2012 6:52:15 PM UTC-5, gboissinot wrote:
>
> From EnvInject 1.75, you are able to use currentJob and currentBuild
> variables in order to access respectively to Job and Run instances.
>
> On Wed, Dec 19, 2012 at 3:58 PM, Matt Felzani
> >
> wrote:
> > 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
>