Add or Export Parameters and Parameter Lists

You might want to set or change parameters in a pipeline job that can be used by downstream jobs in the same pipeline. Or, you might want to add parameters at the start of job execution, based upon data from a Git clone operation, when the cloned repository contains information that will become the value of new parameters or override the value of existing parameters. This parameter can then be used to configure subsequently run jobs, and appear as environment variables in shell scripts run in the build. You might even want to export parameters at the end of job execution, based upon data that was calculated during the build.

Both added and exported parameters would be visible to downstream jobs, which could, in turn, modify a subset of the parameters and then pass them along.

There are two different ways to set parameters dynamically:
  • From a list of parameter definitions that are written in the same manner that environment variables are set in a shell script, that is, from a file with one or more lines that contain PARAMETER_NAME=value definitions.
  • With multi-line values, such as private keys for example, and parameters with sensitive contents like passwords and private keys. These include items that are more complex than those that can be specified using the simple definition format.

All jobs in a pipeline currently see job parameters that have been configured for all jobs in the pipeline. These parameters are collected from the jobs when the pipeline is started, and are added to all jobs that are downstream of the condition that started the pipeline, that is of a triggering job or the “Start” node of a manually-started or a periodically-triggered pipeline. Then, when a job completes, its parameters are extracted and are passed on to any downstream jobs it triggers.

These job parameters can be modified and new parameters can be added in subsequent build steps during a run. This simply adds a way to explicitly direct that parameters be added, both before and after Build steps, like shell scripts, run.

Add a Parameter

The Add a Parameter task runs during build setup, after the Git steps finish running, but before any build steps are run. The task adds a single parameter at a time, potentially allowing a multi-line value (a private key, for example) read from a file, and allows the parameter to be marked sensitive which, by the way, means “Don't print these values in the build log.” You can configure zero or more of these in a job.

Here's how you configure a pre-build task that adds a parameter (or multiple parameters) to a build job:

  1. In the left navigator, click Builds Builds.
  2. In the Jobs overview page, select the job you want to modify and the Jobs Detail page will display.
  3. Click Configure.

    This displays the Job Configuration page.

  4. In the Git tab, click Add Git and select the repository where the file with the parameter is stored.
  5. Click the Before Build tab.
  6. Click Add Before Build Action and select Add Parameter.
  7. In Parameter name, enter the name of the parameter.
  8. In File containing parameter value, enter the name of the file that contains the value for the parameter.
  9. Select the Sensitive checkbox to prevent printing the value of parameters with sensitive contents, like passwords and private keys parameters, in the build log.
  10. Repeat steps 6-8 to add multiple parameters.
  11. Click Save.

Add a Parameter List

The Add a Parameter List task runs during build setup, after the Git steps finish running, but before any build steps are run. The task reads a list, one per line, of one or more parameter definitions in the form PARAMETER_NAME=value and sets the job parameters accordingly. You can configure zero or more of these in a job.

Here's how you configure a pre-build task that adds a parameter list to a build job:

  1. In the left navigator, click Builds Builds.
  2. In the Jobs overview page, select the job you want to modify and the Jobs Detail page will display.
  3. Click Configure.

    This displays the Job Configuration page.

  4. In the Git tab, click Add Git and select the repository where the file with the parameter list is stored.
  5. Click the Before Build tab.
  6. Click Add Before Build Action and select Add Parameter List.
  7. Enter the name of the file that contains the parameter definitions.
  8. Click Save.

Export a Parameter

The Export a Parameter task runs after the build steps have been run. The task adds a single parameter at a time, to allow multi-line values ( a private key, for example) to be read from a file. It also allows the parameter to be marked sensitive which, by the way, means “don't print these values in the build log.” You can configure zero or more of these in a job.

Here's how you configure a post-build task that exports a parameter (or multiple parameters) that can be passed to a downstream build job:

  1. In the left navigator, click Builds Builds.
  2. In the Jobs overview page, select the job you want to modify and the Jobs Detail page will display.
  3. Click Configure.

    This displays the Job Configuration page.

  4. In the Git tab, click Add Git and select the repository with the file where the value for the parameter will be written.
  5. Click the After Build tab.
  6. Click Add After Build Action and select Export Parameter.
  7. In Parameter name, enter the name of the parameter to be exported.
  8. In File containing parameter value, enter the name of the file to write the value for the parameter.
  9. Select the Sensitive checkbox to prevent printing the value of parameters with sensitive contents, like passwords and private keys parameters, in the build log.
  10. Repeat steps 6-8 to export multiple parameters.
  11. Click Save.

Export a Parameter List

The Export a Parameter List task runs after the build steps have been run. The task reads a list, one per line, of one or more parameter definitions in the form PARAMETER_NAME=value and sets job parameters accordingly. You can configure zero or more of these in a job.

Here's how you configure a post-build task that exports a parameter list that can be used by a downstream build job:

  1. In the left navigator, click Builds Builds.
  2. In the Jobs overview page, select the job you want to modify and the Jobs Detail page will display.
  3. Click Configure.

    This displays the Job Configuration page.

  4. In the Git tab, click Add Git and select the repository with the file where the values for the parameter list will be written.
  5. Click the After Build tab.
  6. Click Add After Build Action and select Export Parameter List.
  7. Enter the name of the file where the parameter definitions used in the build job will be written.
  8. Click Save.