Hi,
We have Jenkins 2.0 , Scripted Pipeline and i want to
1. Push an environment variable VAR1=FOO in a Job A, and
2. Access that environment variable from another Job B.
Job A and B both are independent.
When I invoke Job B, I want to go and find the latest build of Job A and then read the value of VAR1.
I tried the below that gives me the 'lastbuld of JobA' but how do i access VAR1 of JobA ?
def currentJob = Jenkins.instance.getItemByFullName('JobA')
def build = currentJob.getLastBuild()
Tried build.getEnvironment() but that gives me environment variables of JobA, NOT the one that I set. Also tried buld.getBuildVariables() but it throws error. I believe the getBuildVariables() method is for 'downstream' jobs.
Any idea how do i do this ?
BTW: I am seeting VAR1=FOO in JobA as env.VAR1="FOO"
Any help much appreciated.
Thanks.