1. 添加组件 Active Choices Plug-in
如jenkins无法联网,可在以下两个地址中下载插件,然后放到/home/jenkins/.jenkins/plugin下面重启jenkins即可
Active Choices
Active Choices | Jenkins plugin
2. 效果如下:
sharding为空时,sharding_info和copy_info不显示
sharding等于2时,显示sharding等于2时的值
3. 具体配置及脚本如下:
在JOB 配置界面添加参数
Groovy Script脚本如下 :
if (sharding=="2") {return """<input name="value" type="text" id="VALUE" class="setting-input" value="this is 2"><img src="error/image/url" style="display: none;" onerror='document.getElementById("VALUE").closest(".form-group").style.display=""'>"""
}else if (sharding=="4") {return """<input name="value" type="text" id="VALUE" class="setting-input" value="this is 4"><img src="error/image/url" style="display: none;" onerror='document.getElementById("VALUE").closest(".form-group").style.display=""'>"""
}else {return """<input name="value" type="text" id="VALUE" class="setting-input" value=""><img src="error/image/url" style="display: none;" onerror='document.getElementById("VALUE").closest(".form-group").style.display="none"'>"""
}