Search code examples
jenkinsgroovyjenkins-pipeline

Jenkins pass value of Active Choices Parameter


I have a jenkins job with "Active Choices Parameter" and "Active Choices Reactive Parameter".

pipeline {
   agent { label 'Agent_Name' }

   stages {
      stage('Build') {
         steps {
            script {
                def res=build job: 'App_Build', parameters: [string(name: 'ActiveChoicesParam', value: 'Dev'),string(name: 'ActiveChoicesReactiveParam', value: 'Server1')]
            }
         }
      }
   }
}

I am trying to call the jenkins job and pass parameter values using pipeline script. However, I am getting the following error:

The parameter 'ActiveChoicesParam' did not have the type expected by App_Build. Converting to Active Choices Parameter.

The parameter 'ActiveChoicesReactiveParam' did not have the type expected by App_Build. Converting to Active Choices Reactive Parameter.

They (Dev and Server1) are valid values - How can I pass these values?


Solution

  • Try setting up as new StringParameterValue's

    build(job: "App_Build",
        parameters: [
            new StringParameterValue('ActiveChoicesParam', 'Dev'),
            new StringParameterValue('ActiveChoicesReactiveParam', 'Server1')
        ],
    )