我正在尝试为我的Jenkins插件进行表单验证。
这是我的插件java源代码。这是一个SimpleBuildStep,有人必须在我的表单中输入一个ID。我只是想让它发挥作用。当我清空场地时,没有任何反应。
public class WATSBuilder extends hudson.tasks.Builder implements SimpleBuildStep {
private String suvId;
private String suvPassword;
@Extension
public static class Descriptor extends BuildStepDescriptor<hudson.tasks.Builder> {
@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return FreeStyleProject.class.isAssignableFrom(jobType);
}
@Override
public String getDisplayName(){
return "Jetson WATS Plugin";
}
public FormValidation doChecksuvId(@QueryParameter String value, @AncestorInPath AbstractProject project) {
if( value.isEmpty() ){
return FormValidation.error("There's a problem here");
} else {
return FormValidation.ok();
}
}
.
.
.
}
这是我的果冻配置:
<f:section title="Environment">
<f:radioBlock title="SUV" value="suv" checked="${instance.isSUVEnv('suv')}" name="env" inline="true">
<f:entry title="SUV ID" field="suvId" >
<f:textbox default="i-xxxxxxxxxxxx" />
<!-- checkUrl="'${rootURL}/plugin/jetson/checkSuvid?val='+this.value" -->
</f:entry>
</f:radioBlock>
<f:radioBlock title="Other" value="other" checked="${instance.isSUVEnv('other')}" name="env" inline="true">
<f:entry title="Endpoint" field="watsEndpoint">
<f:textbox/>
</f:entry>
</f:radioBlock>
</f:section>
答案 0 :(得分:0)
您需要将字段名称大写,因此doCheckSuvId
,而不是doChecksuvId
。