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.
- I have added string parameter.
Also I have provided the "ubuntu" as the label to execute this Project only on the machine that has the label "ubuntu".
In the Build Section, I used Execute shell to print the executor_name.
Click Save.
Parameterized_Project is created.
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.
Click Build.
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.
By selecting the Set by Default will make the default value as true. I need false as default value, so I left unchecked.
Click Save.
Build with Parameters
Now build this project by clicking the Build with Parameters.
- We can see the default values
Provided values
Click build.
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.
In Choice Parameter, the options should be written in line by line.
Option in the First line is considered as the default value.
Click Save.
Build with parameters
Now build this project by clicking the Build with Parameters.
Click build.
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)