如何在Jenkins管道中使用Active Choices反应参考参数(jenkinsfile) [英] How to use Active Choices Reactive Reference Parameter in Jenkins pipeline(jenkinsfile)

查看:388
本文介绍了如何在Jenkins管道中使用Active Choices反应参考参数(jenkinsfile)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现图3.如果不需要更新,请提供默认值.如果需要更新,则给用户输入区域.

I want achieve Picture 3. If no need update, give default value. If need update, then give user input area.

我想在Jenkins管道代码中使用主动反应式引用,而不是在jenkins GUI中使用.检查了示例,但用户无法通过它们输入值自我,只提供选择.如我们所见,Jenkins GUI图片1和2可以使用格式化HTML"来做到这一点,但是我们如何在流水线中使用它或将其转换为流水线呢?

I'd like use active reactive Reference in Jenkins pipeline code, not the jenkins GUI. Checked the example, but user cannot input the value by them self, only provide choices. As we can see the Jenkins GUI picture 1 and 2 can use "Formatted HTML" do this, but how can we use it in pipeline or convert it to pipeline?

推荐答案

========我做到了======这是代码.

========I made it====== here is the code.

 parameters([
                    choice(name:"NeedUpgradePC",choices:['yes','no'],description: "Do you need upgrade your PC"),
                    [$class: 'DynamicReferenceParameter',
                            choiceType: 'ET_FORMATTED_HTML',
                            omitValueField: true,
                            description: 'Please provide a Elastic alias label',
                            name: 'PC_RAM',
                            randomName: 'choice-parameter-5631314456178624',
                            referencedParameters: 'NeedUpgradePC',
                            script: [
                                    $class: 'GroovyScript',
                                    fallbackScript: [
                                            classpath: [],
                                            sandbox: true,
                                            script:
                                                    'return[\'nothing.....\']'
                                    ],
                                    script: [
                                            classpath: [],
                                            sandbox: true,
                                            script:
                                                    """
                                    if(NeedUpgradePC.equals('yes')) {
                                        inputBox="<input name='value' type='text' value='Kingston 8GB'>"
                                    } else {
                                        inputBox="<input name='value' type='text' value='Kingston 8GB' disabled>"
                                    }
                                """
                                    ]
                            ]
                         ],
                            [$class: 'DynamicReferenceParameter',
                                    choiceType: 'ET_FORMATTED_HTML',
                                    omitValueField: true,
                                    description: 'Please provide a Elastic alias label',
                                    name: 'PC_CPU',
                                    randomName: 'choice-parameter-5631314456178624',
                                    referencedParameters: 'NeedUpgradePC',
                                    script: [
                                            $class: 'GroovyScript',
                                            fallbackScript: [
                                                    classpath: [],
                                                    sandbox: true,
                                                    script:
                                                            'return[\'nothing.....\']'
                                            ],
                                            script: [
                                                    classpath: [],
                                                    sandbox: true,
                                                    script:
                                                            """
                                    if(NeedUpgradePC.equals('yes')) {
                                        inputBox="<input name='value' type='text' value='Intel Core i5'>"
                                    } else {
                                        inputBox="<input name='value' type='text' value='Intel Core i5' disabled>"
                                    }
                                """
                                            ]
                                    ]
                            ]

            ])

这篇关于如何在Jenkins管道中使用Active Choices反应参考参数(jenkinsfile)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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