How to use parameterised build with multiple downstream jobs and Jenkinsfiles

I have an upstream and downstream job, that downstream job refers to a Jenkinsfile stored in Github. I assume the values are not being passed on to the Jenkinsfile.

This is what I have:

  1. The upstream job has choice parameters
    parameters {
        choice(
            name: 'WHICH_ACTION',
            choices: ["Stop", "Deploy"],
            description: 'Choose whether to stop or deploy services'
            )
        }

which are being passed on to downstream job


    build job: 'payment/payment-provider-api', propagate: false
                                parameters: [
                                   string(name: "WHICH_ACTION", value: params.ACTION),
                                ]
  1. The Jenkinsfile should take the values from the Upstream job
    stages {
        stage('Stop') {
         when {
              expression { ACTION == 'Stop' }
         }

I use parameterised build plugin.
I get an error. Is it because my syntax is incorrect or because the values are not passing? Any advice appreciated

You probably are mixing up parameter names
upstream → defines WHICH_ACTION
downstream → wants ACTION

so your call should look like:

job ( parameters: [ string(name:'ACTION', value:params.WHICH_ACTION)])

Thank you! I will leave your solution, as it is most likely the correct one, but I still get an error.
When I remove the parameters, the build works, so it’s most likely due to parameters not getting passed on. I have parameterized build plugin, is there anything else needed to make sure the values are passed on to the jenkinsfile?

The downstream job needs to declare the parameters of course, jobs discard all unknown parameters.