主动选择詹金斯管道中的无功参考参数 [英] Active Choices Reactive Reference Parameter in jenkins pipeline

查看:840
本文介绍了主动选择詹金斯管道中的无功参考参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我现在想要的是如何在jenkinsFile中使用activeChoiceReactiveParam进行管道工作,我做到了这一点:

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

但是我怎样才能添加choice2参数!!! 不是使用主动选择反应参考参数我做到了,它的工作!

  node('slave'){
def choice1
def choice2

stage('Select'){
choice1 = input(id:'userInput',message:'选择您的选择',参数: [[\ $ class:'ChoiceParameterDefinition',options:'aa\\\
bb',description:'',name:'']])
if(choice1.equals(aa)){
choice2 = input(id:'userInput',message:'选择您的选择',参数:[[\ $ class:'ChoiceParameterDefinition',选项:'yy\\\
ww',描述:'',name:' ']])
} else {
choice2 = input(id:'userInput',message:'Select your'',parameters:[[\ $ class:'ChoiceParameterDefinition',options:'gg \\\
kk',description:'',name:'']])
}
}
}


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')
                  }

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\nbbb',
                                    description: 'select your choice : ',
                                    name       : 'choice1'
                            ]

but how can i add the choice2 parameter !!!

解决方案

Instead of using the Active Choices Reactive Reference Parameter i did that and it's work !!

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: ''] ])
        }
    }
}

这篇关于主动选择詹金斯管道中的无功参考参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆