如何在 Jenkins 管道中使用 Active Choices Reactive 参考参数(jenkinsfile)

2023-12-03

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

我想在 Jenkins 管道代码中使用主动反应参考,而不是 jenkins GUI。检查了example,但用户不能自己输入值,只能提供选择。正如我们所看到的 Jenkins GUI 图 1 和 2 可以使用“格式化 HTML”来做到这一点,但是我们如何在管道中使用它或将其转换为管道?

enter image description hereenter image description hereenter image description here


========我成功了======这是代码。

 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>"
                                    }
                                """
                                            ]
                                    ]
                            ]

            ])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Jenkins 管道中使用 Active Choices Reactive 参考参数(jenkinsfile) 的相关文章

随机推荐