我在dsl作业中使用Active Choices反应参考参数插件,此处代码
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进行管道作业,这很好,我做到了:
properties( [ [ $class : 'ParametersDefinitionProperty', parameterDefinitions: [ [ $class : 'ChoiceParameterDefinition', choices : 'aaa\nbbb', description: 'select your choice : ', name : 'choice1' ]
但是我怎么能添加choice2参数!
而不是我在下面做的使用 主动选择反应式参考参数 ,它工作正常!
node('slave') { def choice1 def choice2 stage ('Select'){ choice1 = input( id: 'userInput', message: 'Select your choice', parameters: [ [\$class: 'ChoiceParameterDefinition', choices: 'aa\nbb', description: '', name: ''] ]) if(choice1.equals("aa")){ choice2 = input( id: 'userInput', message: 'Select your choice', parameters: [ [\$class: 'ChoiceParameterDefinition', choices: 'yy\nww', description: '', name: ''] ]) }else{ choice2 = input( id: 'userInput', message: 'Select your choice', parameters: [ [\$class: 'ChoiceParameterDefinition', choices: 'gg\nkk', description: '', name: ''] ]) } } }