Activity: Setting up Parameterized Projects and Accessing Parameters

Scenario

You have been asked to set up a freestyle project that will contain two string parameters, your first and last names, and a build step executing a bash script that will display the greeting Hello followed by your full name.

Aim

To set up parameterized projects and access parameters

Prerequisites

Ensure the following:

  • Jenkins is up and running
  • You are logged in as the Administrator

Steps for Completion

  1. On the Jenkins dashboard, go to the configuration panel and select New Item.
  1. On the New Item view, enter a project name, select Freestyle project, then select OK.
  1. Under the general section of the project configuration, enter an appropriate project description.
  1. Enable the checkbox This project is parameterized to allow you to add parameters to the project, as shown in the following screenshot:
  1. Add the first parameter by clicking on the Add Parameter drop-down menu and selecting String Parameter, as shown in the following screenshot:
  1. Fill in the form with the details of the first parameter, that is, your first name, as displayed. This will present us with the form shown in the following screenshot:
  1. Follow the same procedure to create the second parameter for your last name. The final configuration should look like the following screenshot:

Our project now has two string parameters containing our first and last names. We can now proceed to add the build parameter to display the desired result.

  1. In the build section of the project configuration, select the Add build step drop-down menu and select Execute shell, as shown in the following screenshot:
  1. This presents us with a form requiring us to insert the command we want to execute. Populate the text area as shown in the following screenshot:
  1. Press Apply and Save at the bottom of the screen to save your project configuration. This will direct you to the project dashboard.
  2. On the left-hand project options menu, select Build with parameters to build the project:
  1. Fill in the parameters if you are not comfortable with running the project with the default parameters. Select Build.
  1. On the build history on the left, hover over the build number and select Console Output, as shown in the following screenshot:

From the Console Output, we can see that the build successfully displayed our first and last name, with the greeting as displayed on the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.71.146