詹金斯.使用下拉按钮选择其他选项 [英] Jenkins. Using drop down button to select different options

查看:55
本文介绍了詹金斯.使用下拉按钮选择其他选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道哪个插件是最好的选择.但是我想构建一个带有参数的作业,其中只有两个选项.选项A和选项B.

I don´t know which plugin is best option for this. But I would like to have a build with parameters job in which I have only 2 options. Option-A and Option-B.

如果我选择选项A,则不会发生任何奇怪的情况,您可以按构建"按钮开始工作.假设该作业仅具有sh "echo hello" 但是,如果我选择选项B(也许有一些单选按钮),我希望出现一个文本框,并且该用户输入一个字符串值并开始工作.那么该值将在pipline中用于执行获取该值的相同命令.

If I choose Option A, nothing strange should happens and you can hit build button for starting job. Suppose that job only has sh "echo hello" But if I choose Option B (maybe some radio buttons), I would like that a textbox appears, and that user enter a string value and starts job. then that value will be used in pipline to execute same command grabbing that value.

例如,如果用户在文本框PETER中输入,则Job为:sh"echo hello {$ textvalue}(PETER).

For example, If user entered in textbox PETER, Job would be: sh "echo hello {$textvalue} (PETER).

我能够使用像这样的简单代码并使用String参数来做到这一点.

I was able to do this with simple groovy code like this and using String parameter.

def var1 = params.TEXT

node {

      stage('show text') {

          sh (""" echo hello $var1 """)


      }

但是我该如何使用单选按钮选项(或类似功能)来做到这一点? .我尝试使用主动选择参数和主动选择反应参数.但这并不能满足我的要求,如果我选择选项A并只是运行作业,那么它只会显示一个文本框,而如果选择选项B则什么都不会显示.

But how Can I do this with a radio buttons options (or something similar)? . I tried with Active choice parameter and active choice reactive parameter. But this doesn´t accomplish what I want, which is to appear just a textbox if I choose option-A and just run the job and nothing shows up if you choose option-B.

谢谢!

(已编辑)

推荐答案

在反应式参数配置中,您需要用Groovy编写代码,该代码返回修改HTML页面的Javascript,设置例如display: none.我们有这个工作.

In Reactive parameter configuration, you need to write a code in Groovy that returns Javascript that modifies the HTML page, setting e.g. display: none. We have this working.

或者,您可能希望配置两个参数,并在第二个参数的描述中写一些内容,以仅在选择了选项B时才相关".

Alternatively, you may want to configure two parameters, and write in the description of the second one something to the tune "only relevant when option B is selected."

这篇关于詹金斯.使用下拉按钮选择其他选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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