Accessing user build variables of another build

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing user build variables of another build

Yasin Jamal
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.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1536195463.5250882.1565787195573%40mail.yahoo.com.
Reply | Threaded
Open this post in threaded view
|

Accessing user build variables of another build

Martin d'Anjou
Have a look at https://github.com/jenkinsci/run-selector-plugin/blob/master/README.md

Martin

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7601585c-93eb-447d-92bb-709c95add3fc%40googlegroups.com.