如何在JENKINS中具有相关参数 [英] How to have dependent parameters in JENKINS
问题描述
Jenkins是否支持(开箱即用的插件)具有定义依赖参数的方式.例如:如果我在选择参数中有三个字段供用户输入,并且在第一个字段中选择了选项A(考虑到它会为您提供选项列表),则应仅向用户显示其他相关字段以进行填写out(在进行构建时),类似地,如果用户选择B,它应该显示其余的其他相关选项
Does Jenkins support (out of the box plugin) to have a way of defining dependent parameters. For ex: If I have three fields in a choice parameter for user to input, and if I select option A (considering it gives you a list of options) in the first field, then only other dependent fields should be shown to user to fill out(while doing the build), Similarly if user selects B , it should show rest of the other relevant options
致谢
推荐答案
您可以使用Active Choice Reactive Reference参数对源参数执行基本的if/then.这不能解决不希望显示参数的问题.
You can do a basic if/then on a source parameter using an Active Choice Reactive Reference parameter. This does not solve the problem of not wanting parameters to display or not though.
如何在构建参数上执行if/then设置另一个构建参数
================================================== ========================
对于初学者,您需要使用"Active Choices"插件.
1)源参数
创建一个典型的选择参数-我们将其称为选择",并为其选择"val1","val2","val3","val4"
2)派生参数
创建主动选择反应式参考参数".
名称:您希望参数被调用/被引用为
的名称
检查"Groovy脚本"
脚本:
How to do an if / then on a build parameter, setting another build parameter
============================================================================
You need the "Active Choices" plugin for starters.
1) The source parameter
Create a typical choice parameter - We'll call it "Choose", and give it the choices "val1", "val2", "val3", "val4"
2) The derived parameter
Create an "Active Choices Reactive Reference Parameter".
Name: What you want the parameter to be called / referenced as
Check "Groovy script"
The script:
if (Choose.equals("val1")) {
return "<input name=\"value\" value=\"Something because we chose val1\" class=\"setting-input\" type=\"text\">"
} else if (Choose.equals("val2")) {
return "<input name=\"value\" value=\"Something because we chose val2\" class=\"setting-input\" type=\"text\">"
} else if (Choose.equals("val3")) {
return "<input name=\"value\" value=\"Something because we chose val3\" class=\"setting-input\" type=\"text\">"
} else if (Choose.equals("val4")) {
return "<input name=\"value\" value=\"Something because we chose val4\" class=\"setting-input\" type=\"text\">"
}
选择类型:
格式化的隐藏HTML
-或-
格式化的HTML-用于测试,因此您可以看到正在设置的参数
引用的参数:源参数的名称-选择"
Choice type:
Formatted hidden HTML
-- or --
Formatted HTML - For testing so you can see the parameter being set
Referenced parameters: The name of the source parameter - "Choose"
这篇关于如何在JENKINS中具有相关参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!