【问题标题】:How can I know which radio button is selected in Jenkins?我如何知道在 Jenkins 中选择了哪个单选按钮?
【发布时间】:2015-08-11 10:30:20
【问题描述】:
我如何知道在 Jenkins 中选择了哪个单选按钮?
我的代码示例:
<f:section title="Select or upload application file">
<f:radioBlock checked="true" name="file" value="" title="Upload new version" inline="true">
<f:entry title="File Path" field="appFile">
<f:textbox/>
</f:entry>
<f:entry title="New Version" field="newVersion">
<f:textbox/>
</f:entry>
</f:radioBlock>
<f:radioBlock checked="false" name="file" value="" title="Available versions" inline="true">
<f:entry title="" field="oldVersion">
<f:select/>
</f:entry>
</f:radioBlock>
</f:section>
【问题讨论】:
标签:
jenkins
jenkins-plugins
jelly
【解决方案1】:
从这个开始的一个好地方是寻找其他插件。
果冻here看起来像这样
<f:radioBlock name="testToRun" value="BUILTIN_FUZZ" checked="${instance.isTestType('BUILTIN_FUZZ')}" title="Built-in Fuzz" inline="true">
<f:nested>
<f:entry title="Event Count" field="eventCount" description="[Optional] Number of fuzz events.">
<f:textbox/>
</f:entry>
<f:entry title="Event Throttle" field="eventThrottle" description="[Optional] Number for event throttle.">
<f:textbox/>
</f:entry>
<f:entry title="Seed" field="seed" description="[Optional] Seed to use for randomizing events.">
<f:textbox/>
</f:entry>
</f:nested>
</f:radioBlock>
它使用了here定义的函数
public String isTestType(String testTypeName) {
return this.testToRun.equalsIgnoreCase(testTypeName) ? "true" : "";
}
您需要将选中的属性绑定到实例中的某些内容
checked="${instance.isTestType('BUILTIN_FUZZ')}"
并且在类上有一个公共属性
public String testToRun;
并将该字段添加到 DataBoundConstructor
@DataBoundConstructor
@SuppressWarnings("unused")
public AWSDeviceFarmRecorder(String projectName,
String devicePoolName,
String appArtifact,
String testToRun,
你已经拥有了
inline="true"
因此您不必添加带有自己的 DataBoundConstructor 的内部类。