Jenkins How to Pass Parameters to downstream Job

Sharing buttons:

hello and welcome to this session today

we will learn how to pass parameter or

parameters from one job to another

downstream job in Jenkins and for this

we are going to use parametrized trigger

plugin and this is going to be very easy

and very interesting so let's get

started and step number one will be we

have to start our Jenkins so in my case

I already have started my Jenkins and

you can see my Jenkins dashboard here

and then what we have to do is we have

to go to manage Jenkins and we have to

go to manage plugins so I have my manage

plugins here I will go to manage plugins

and here is my manage plugins page so

step number two is we have to go to

manage Jenkins and then go to manage

plugins now here if you go to your

available section of your plugins you

can search for a plug-in called

parametrized trigger plug-in this one or

in case you already have it you will

find it in your install section so in my

case I already have it so if I go to the

installed section and search for this

let me just see and yes you can see here

it is parametrized trigger plug-in so

you have to get this you can go to your

available section and then install

without restart or download and install

after restart and once you have this

plug-in then we will go back to our

dashboard and now here you must be

having a job that is parametrized now I

already have a section of video on how

to create parametrize jobs in Jenkins so

if you go to my channel here or on my

udemy course as well here in Jenkins

tips and tricks playlist let me just

show you if I go to the playlist the

very first video here is how to

parameterize jobs in Jenkins so I will

also make this link available in the

node so that you can just refer this and

also here is a link for this plugins

wiki page so if I go to this

particular link let me just show you

here is the link so this is the wiki

page for this particular parameterize

trigger plug-in and you can read the

documentation here it is very easy you

can just pass the parameters like this

and I will show you how so here I have

this parametrized job that I earlier

created and if I go here you can see if

I go to the configure section of this

job here I have selected this project is

parametrized and I have used a string

parameter and I have given name here and

the value S Rogoff

and if I go to the build section here I

am saying echo percentage name

percentage so I am on Windows I am using

percent if you are on Mac or Linux you

can also use you can call the parameters

with dollar and then in the curly braces

you can give the variable name or you

can just say dollar and the a variable

or parameter name all this I have

explained in this video how to

parameterize job in Jenkins so you can

watch that so here if I run this job let

me just run this job and show you I will

say apply and save and I will say built

with parameters and here you can see I

am getting this parameters I can this is

a default value I can change this as

well here and then I can say build so

this will build and you can see this is

the third run of this job and if I go to

the output control output you can see it

is printing the value of the parameter

name which is Raghav so this is what we

find now if I have to pass this

particular value from another job in

that case what I will do is I will just

go to my Jenkins and create a new job so

let me also head the steps here create a

parametrized job which we have already

done and step number four is create a

new upstream job this is the job from

where we will pass the parameter so I

will say new item and I will say this is

parametrized I will say this is

parametrized trigger job and say

freestyle project and say okay and here

I believe everything and just directly

go to the post build actions and here in

the post productions you will find this

option trigger parameterize build on

other projects and this option you will

only get once you have added the

parametrized trigger plug-in so I will

select this and here is the details so

first we have to select the project so

the project that we want to run is

parametrized job this one so let me add

this here yes and then here is the

option trigger when build is stable

unstable failed and so on so it it is

asking us if you want to run this job

only when this particular job is stable

or not so I am saying this should be

stable and then here we have the option

to add parameters now what I am going to

do is I am going to use the predefined

parameters you can also pass any

parameters which are variables from this

job but I am going to use predefined

parameters of that job and here I can

just give the value I can say name

equals I am saying automation okay so

step number five will be in post build

actions pasta parameters so this is what

I am doing and now I will say apply and

save and you can add multiple parameters

and you can also add multiple projects

here and now you can see let me just go

back to my Jenkins dashboard and also

open this job parametrized job and you

can see there are as of now

turns off this job and now the fourth

run will happen when I will trigger this

upstream job so I'm going to trigger

this now I will say build now and this

will build and then it will trigger this

particular job and you can see this has

already triggered which is in queue and

this is now building let us go to the

output and you can see it is now taking

the parameters as automation which is

coming from this upstream job so this is

how you can use the parametrized trigger

plug-in and there are many options that

you can explore in this plugin I hope

this session was very useful for you

thank you for watching