How to pass one of the jobs output value to the next job input in pipeline script

29 views
Skip to first unread message

pbasan...@gmail.com

unread,
Apr 16, 2019, 4:18:52 AM4/16/19
to Jenkins Users
Hi All,

I have a pipeline script job and is triggering Jobs.
The requirement here is to pass one of the jobs output value to the next job .

1.How to get the value from job to the Pipeline job.
2.From Pipeline how to pass that values to the next job.

Regards,
Basanta

ZillaYT

unread,
Apr 16, 2019, 10:57:23 AM4/16/19
to Jenkins Users
Say you want JobA to trigger JobB

On JobA's pipeline code do

build job: JobB, parameters: [string(name: 'PARAMETER_NAME', value: 'PARAMETER_VALUE')], wait: false

The 'wait' parameter indicates if you want JobB to finish before JobA does (true), or JobA to finish even before JobB does (false).


Jenkins has built-in environment variables that you can pass around between jobs, or you can pass any of JobA's variables to JobB.


Chris

pbasan...@gmail.com

unread,
Apr 19, 2019, 1:08:24 AM4/19/19
to Jenkins Users
Thanks .. 
The question is how to access the variables returned from Job1 in the pipeline .. 
Once you access the variables, can pass the same value to second job .

Job 1: Exported variable  : export Docker_image=ABC
Pipeline job :
def j1BuildResult = build job: 'J1'
def j1EnvVariables = j1BuildResult.getBuildVariables();

>> Here not able to access the variables Docker_image (This value want to pass to next job)


Regards,
Basanta
Reply all
Reply to author
Forward
0 new messages