简体   繁体   中英

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?

Try setting up as new StringParameterValue's

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

somehow new StringParameterValue( 'key', 'value' ) doesn't work for me. I'm using;

List<ParameterValue> newParams = [
  [$class: 'StringParameterValue' , name: 'ActiveChoicesParam'   , value: 'Dev' ] ,
  [$class: 'StringParameterValue' , name: 'ActiveChoicesReactiveParam', value: 'Server1'] ,
]

def res = build ( job: 'App_Build' ,
  propagate  : false ,
  wait       : true  ,
  parameters: newParams
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM