主动选择无参考参数在詹金斯管道
问题描述:
我使用的是主动选择无参考参数插件在DSL工作在这里的代码主动选择无参考参数在詹金斯管道
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')
}
和它的工作的罚款我现在想的是如何使用activeChoiceReactiveParam在jenkinsFile管道工作我做到了这一点:
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: ''] ])
}
}
}
答
尝试类似的东西:
properties(
[
[
$class : 'ParametersDefinitionProperty',
parameterDefinitions: [
[
$class : 'ChoiceParameterDefinition',
choices : 'aaa\nbbb',
description: 'select your choice : ',
name : 'choice1'
],
[
$class : 'ChoiceParameterDefinition',
choices : 'ccc\nddd',
description: 'select another choice : ',
name : 'choice2'
]
choice2取决于choice1;如果用户选择choice1作为“aaa”而不是选择2上的选择将是“cc”或“dd”,并且如果用户选择choice1作为“bbb”而不是选择2上的选择将是“ee”或“rr” – Ibtissam