DEV Community

Logesh Sakthivel
Logesh Sakthivel

Posted on

Create Parameterized job in Jenkins

Some of our projects need parameters to be passed as an input while executing/building the Project. For that we can make our Project as parameterized.
In this article we are going to create a Project in Jenkins that uses some input parameters.


Create Project

Create a Freestyle Project in Jenkins.

In the Project's Configuration page select the "This project is parameterized" option. And add the Parameters.

This project is parameterized

  • I have added string parameter.

Add parameter

Also I have provided the "ubuntu" as the label to execute this Project only on the machine that has the label "ubuntu".

Execute

In the Build Section, I used Execute shell to print the executor_name.
Execute shell

Click Save.

Parameterized_Project is created.

Parameterized_Project

Build with Parameters

Now build this project by clicking the Build with Parameters.
It prompts for the executor_name value with the default value as Logesh.

Build

Click Build.

Console output


We can also add other types of parameters. Above, we have seen the string parameter.

Boolean Parameter

In the same Project, goto configure and add an Boolean parameter.

Boolean Parameter

By selecting the Set by Default will make the default value as true. I need false as default value, so I left unchecked.

Execute shell

Click Save.

Build with Parameters
Now build this project by clicking the Build with Parameters.

  • We can see the default values Default values

Provided values

Build

Click build.

Console output

Choice Parameter

In the same Project, goto configure and add a Choice parameter.
Choice is like a Dropdown options, we can select any one from the given choices.

Choice Parameter

In Choice Parameter, the options should be written in line by line.
Option in the First line is considered as the default value.

Execute shell

Click Save.

Build with parameters

Now build this project by clicking the Build with Parameters.

  • Default values
    Default values

  • Passed values
    Provided values

Click build.

Console output


In this article we have seen how to create a Parameterized project with String, Boolean and Choice parameters.

Hope you have learned something new here.
Happie Learning :)

Top comments (0)