Building Parameterized Script in Jenkins

13 / Mar / 2015 by Mohit Dayal Gupta 2 comments

Jenkins is an extensible open source continuous integration server. Using Jenkins we can perform the tasks automatically from our server or localhost. A script is created and built just once . Then, you can run the script by just clicking on Build link in Jenkins. The scripts can be scheduled using Jenkins. You can visit the following link: Installation Steps of Jenkins to check out the installation steps. In this blog, it will be explained that how to BUILD PARAMETERIZED SCRIPT IN JENKINS.

The complete steps have been detailed below:

  • Go to the Jenkins console by going to your localhost or the platform at which you install it.
  • The screen will appear as shown below:


Selection_016

 

  • Click on New Item link on the left pane. The new console will appear as shown below.

Selection_017

 

  • Give the Item Name to your job and choose a project. I have chosen Freestyle Project here. After entering the details, click on OK button. The new console will appear as shown below.

Selection_018

 

  • Enter the adequate details above and then check the option “This build is parameterized.” New options will then open up. You can choose any type of parameters that you wish to give during build.  Here I’m choosing String Parameter  to show an example. Selection_025

 

 

  • Give a name to your String parameter. You can add any number of parameters you want. In this example, i have taken two string parameters- Name and Practice. Now during the build it will ask for the two parameters and then use these parameters. Now click on Apply. Now choose Add build Step and then choose Execute shell.  Enter your script in the textbox provided. I have entered the bash script to print Name and Practice. Click on Apply and Save.

Selection_019

 

 

  • Now you will get the option of Build with Parameters instead of Build. Click on the link and enter the parameters.

 

Selection_020

 

 

 

  • Enter the parameters in the textbox specified.Selection_026

 

  • After entering the parameters click on Build . Your Job has been successfully built. Now go to your build and click on Console.

Selection_022Selection_023

 

The script has been executed successfully and the parameters that you entered are shown in the Console Output.

 

 

 

 

 

FOUND THIS USEFUL? SHARE IT

comments (2)

  1. Mohit Dayal Gupta

    There is nothing more satisfying than the blogpost helping out someone. Looking forward to help you more .

    Reply

Leave a Reply

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