How do I create a parameterized project

Issue

  • How do I create a parameterized build?

Environment

  • Cloudbees Jenkins Enterprise
  • Jenkins

Resolution

A project has the option to have a build be parameterized. What this means is that the job can execute with specific parameters (like version number, server url, node name, etc.).

To add parameters to a freestyle project (this can apply to any other project type, but in this example I will be using freestyle project):

  1. Create a freestyle project.
  2. In the job configuration page is the option “Add Parameters”.
  3. There is a drop-down option to configure parameterized build options (like a boolean attribute, or a string attribute).
  4. Save the project.

You will notice that the “Build Now” text has changed to “Build Now with Parameters”, and clicking on the link provides you the option to set those parameters for the build.

The next step would be to make sure that the configuration is usable within your project. To do that you can encapsulate the name of the variable in ${name} where name is the name of the parameter name.
To verify that the configuration works I would recommend creating a shell step which has the following:

echo "${name}"

This will output the contents of the name parameterized option. Once you confirm that is the correct output, then you can use that parameterized build variable anywhere in the build.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.