【问题标题】:Jenkins pass value of Active Choices ParameterJenkins 传递 Active Choices 参数的值
【发布时间】:2020-02-19 17:12:11
【问题描述】:

我有一份带有“Active Choices Parameter”和“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')]
            }
         }
      }
   }
}

我正在尝试调用 jenkins 作业并使用管道脚本传递参数值。但是,我收到以下错误:

参数“ActiveChoicesParam”不属于预期的类型 应用程序_构建。转换为主动选择参数。

参数“ActiveChoicesReactiveParam”不属于预期的类型 应用程序_构建。转换为 Active Choices 反应参数。

它们(Dev 和 Server1)是有效值 - 我如何传递这些值?

【问题讨论】:

    标签: jenkins groovy jenkins-pipeline


    【解决方案1】:

    尝试设置为新的StringParameterValue的

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

    【讨论】:

      【解决方案2】:

      不知何故new StringParameterValue( 'key', 'value' ) 对我不起作用。我正在使用;

      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
      )
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-29
        • 2016-01-18
        • 2023-03-29
        • 2021-10-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多