Email: info@zenconix.com

Create Parameterized job in Jenkins

Published on: 12/28/20 11:56 AM

Category:DevOps Jenkins Tags: , ,

In last post, we have seen how to create simple job in Jenkins.

Now, in this post we will take a look on how can we create parameterized job in Jenkins.

Lets start with creating new project. Click on new item, and create freestyle project as below and hit OK button

From general setting, select checkbox – “This project is parameterized”

Now click on “Add Parameter” button

you can add parameter of type which ever you want , I am selecting string parameter for now.

Add some values to there, it is in combination of key value pair

so in above example, “Name” will be the key and default value will be “ZenConix”, this value can be change later. Description is optional here.

Now scroll down , into build section, select “Execute Windows batch command”

For test purpose, we are going to print back the value of our string parameter.

if you are on windows, then to get the value of parameter you need to write key in % example in our case it would be %name% but if you are on mac or linux, then you need to write in with $ sign and in curly braces as ${name}

Now click on save job and our job is ready.

but if you observe this, this time we have “Build with Parameter” instead of just build option.

Click on “Build with parameters” and you can input the string parameter here

Click on build button to build this job.

Project build successfully, you can see history in Build history section

Click on #1 to see output of the project.

Inside console output, you can see our build statement as well as output of our windows batch command

we also can add more parameter here, to add more parameter, go to project and click on “configure”

Click on “Add parameter”, this time, we are going to add Boolean parameter

Added new parameter by name “TestCompleted” with default value as false as I have unchecked checkbox for default value

Click on Save and our configuration is ready. Now again click on “Build with parameters”. this time you can see new parameter which is boolean value as there is checkbox to check.


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Send email by Jenkins

In this post, we are going to take a look on how to setup basic email configuration for Jenkins and send mail if build job fails. First and formost, make sure, you have installed some email plugin so that it will allow you to configure email setup. You can install any email extension plugin example […]

Understand build triggers in Jenkins

Hello All, Before getting started to understand build triggers in Jenkins, it is highly recommended to see previous post about Jenkins on our blog so that you will have good idea about Jenkins and will help to understand this post. Lets get started, in previous post, we have seen how to create simple job in […]

Create simple jobs in Jenkins

In this post, we are going to see how to create jobs in Jenkins. If you are coming here at first time, I recommend to go to my previous post where we have explained about how to have initial setup for Jenkins in link below. Now, lets get started to create job in Jenkins Give […]