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:
- Click on New Item link on the left pane. The new console will appear as shown below.
- 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.
- 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.
- 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.
- Now you will get the option of Build with Parameters instead of Build. Click on the link and enter the parameters.
- Enter the parameters in the textbox specified.
- After entering the parameters click on Build . Your Job has been successfully built. Now go to your build and click on Console.
The script has been executed successfully and the parameters that you entered are shown in the Console Output.