詹金斯管道中的主动选择反应参考参数

问题描述:

我在此处的 dsl 作业中使用 Active Choices Reactive Reference Parameter 插件代码

I'm using the Active Choices Reactive Reference Parameter plugin in a dsl job here the code

 parameters {
                  activeChoiceParam('choice1') {
                      description('select your choice')
                      choiceType('RADIO')
                      groovyScript {
                          script("return['aaa','bbb']")
                          fallbackScript('return ["error"]')
                      }
                  }
                  activeChoiceReactiveParam('choice2') {
                      description('select your choice')
                      choiceType('RADIO')
                      groovyScript {
                          script("if(choice1.equals("aaa")){return ['a', 'b']} else {return ['aaaaaa','fffffff']}")
                          fallbackScript('return ["error"]')
                      }
                      referencedParameter('choice1')
                  }

而且它工作正常我现在想要的是如何在 jenkinsFile 中使用 activeChoiceReactiveParam 进行管道作业我这样做了:

and it work's fine what i want now is how to use the activeChoiceReactiveParam in a jenkinsFile for pipeline job i did that :

properties(
    [
            [
                    $class              : 'ParametersDefinitionProperty',
                    parameterDefinitions: [
                            [
                                    $class     : 'ChoiceParameterDefinition',
                                    choices    : 'aaa
bbb',
                                    description: 'select your choice : ',
                                    name       : 'choice1'
                            ]

但是我如何添加choice2参数!!!

but how can i add the choice2 parameter !!!

我没有使用 Active Choices Reactive Reference Parameter 我在下面做了,它工作正常!!!

Instead of using the Active Choices Reactive Reference Parameter i did below and it's working fine !!!

node('slave') {
    def choice1
    def choice2

    stage ('Select'){
        choice1 = input( id: 'userInput', message: 'Select your choice', parameters: [ [$class: 'ChoiceParameterDefinition', choices: 'aa
bb', description: '', name: ''] ])
        if(choice1.equals("aa")){
            choice2 = input( id: 'userInput', message: 'Select your choice', parameters: [ [$class: 'ChoiceParameterDefinition', choices: 'yy
ww', description: '', name: ''] ])
        }else{
            choice2 = input( id: 'userInput', message: 'Select your choice', parameters: [ [$class: 'ChoiceParameterDefinition', choices: 'gg
kk', description: '', name: ''] ])
        }
    }
}