How to pass parameter to downstream job in Pipeline job?

Article ID:221400287
1 minute readKnowledge base

Issue

I would like to pass a parameter value to a downstream job in a Pipeline job.

Environment

  • CloudBees Jenkins Enterprise

  • Pipeline

Resolution

Example:

Assume that I have a downstream freestyle job named downstream-freestyle, that contains two String parameters, named ParamA and ParamB.

In the upstream Pipeline job:

node {
    paramAValue = "paramAValue"
    paramBValue = "paramBValue"
    build job: 'downstream-freestyle', parameters: [[$class: 'StringParameterValue', name: 'ParamA', value: paramAValue], [$class: 'StringParameterValue', name: 'ParamB', value: paramBValue]]
}

Reference:

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.