In Jenkins how to pass a parameter from Pipeline job to a freestyle job

21 views
Skip to first unread message

Geo PC

unread,
May 2, 2018, 9:43:06 AM5/2/18
to Jenkins Users

I am running a pipeline job and with this we need to pass a parameter to a downsteam job but its not working. We tried as follows:


Pipeline JOB:

node {
    parameters {
            choice(
                name: 'OS',
                choices:"Windows\nLinux\nMAC",
                description: "Choose Environment to build!")
                }
    stage('Build') {
        if("${params.Environment}" == 'Windows')
        {
       paramAValue = "${params.Environment}"
       build job: 'QA-Test-Windows',parameters: [[$class: 'StringParameterValue', name: 'ParamA', value: "$paramAValue"]]
        }
    }
    }

QA-Test-Windows is a Freestyle job and in that we tried accessing the parameter in script as follows but its not working.


Write-output "OS selected for testing is ${params.ParamA}"

Write-output "OS selected for testing is ${ParamA}"

Tried accessing variables but its not working. Can anyone please help me on this. We tried creating QA-Test-Windows freestyle job as Pipelinejob but in this freestyle there are lot of Build steps.

Victor Martinez

unread,
May 2, 2018, 11:45:32 AM5/2/18
to Jenkins Users
Wrong parameter name: Environment is not the name of the parameter but 'OS' therefore if you replace  'params.Environment' with 'params.OS'  it should work

Reply all
Reply to author
Forward
0 new messages