Create Parameterized job in Jenkins
Tags: jenkins, cicd
Published: 2023-06-07 13:47:27

_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q1aq7z1smx2gdybpn69k.png)

- I have added string parameter.

![Add parameter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ilxfw8nmfpbjg4ofwg7.png)

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


![Execute](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l88u7nado7ll6kb2ijp7.png)


In the Build Section, I used Execute shell to print the **executor_name**.
![Execute shell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q65fnwnr99e6pyqi2w03.png)

Click Save.

Parameterized_Project is created.


![Parameterized_Project ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lpbr25h5ixljn9a6vw1p.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ygzqjjnv6vc7oub93rv.png)

Click Build.

![Console output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iuqxzihdmr1cwmuj80dt.png)

---

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dphgixpb1govpfk7d63.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4a5ht542g6qjx5uyy6q.png)

Click Save.

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

- We can see the default values
![Default values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dmwtj5a0gkiyd1h3k8vj.png)

Provided values

![Build](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2r8v097w72dnvdvg8sc8.png)

Click build.


![Console output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u52514lwanpp35ufj6nt.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqq2o1so1rye6ntl2pwz.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3j33b9ott56bcz2r4s31.png)

Click Save.

**Build with parameters**

Now build this project by clicking the Build with Parameters.

- Default values
![Default values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/brusku63a83mrtekawtp.png)

- Passed values
![Provided values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7p8rszkcvat1o8zqy6p6.png)


Click build.


![Console output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ajiaayapgygvfvndby1.png)

---

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 :)