Create a Parameterized Job

This example will show that how to create a Jenkins job that will take input from the drop-down using parameters aka parameterized job.

Step 1. Create a freestyle Job.

Create a freestyle job with an appropriate name.

Step 2. Create Parameters for dropdown.

✔  Check This project is parameterized in the General section

✔  Click Add Parameter.

✔  Choose Choice Parameter

 

parameters

 

Step 3. Configure Choice Parameter

Configure the fields as follows

✔  Name – give a suitable name for your parameter. For eg. OS

✔  Choices – give the values one per line that will appear in the drop-down option.

✔  Description – describe the parameter.

 

choice-parameter

 

Step 4. Configure Build Step.

✔  Choose Execute Shell and print something using the parameter. For eg.

echo ‘The Jenkins is installed on ’ $OS.

 

 

parameterized-shell

 

✔  Apply and Save.

 

Step 5. Build the project.

✔  Click on Build with Parameters

✔  Choose any value from the drop-down and click on Build.

 

build-with-parameter

 

Step 6. Check the Console Output.

In the console, the selected value gets printed instead of $OS. You build the project with different values from the drop-down and you will always get the selected value in console output.

 

parameterized-job-console

 

Assignment:

Create a Jenkins Job where drop-down and checkboxes are being used for multiple Values.