Skip to content

Commit e30f881

Browse files
kienanstewartmjeanson
authored andcommitted
Use 'modern' checkUrl validation
This avoids 404 errors when attempting to validate the startupTimesToRetryOnFailure and startupWaitingPeriodSeconds fields when adding or editing a computer with Jenkins 2.541. This form is available since Jenkins 2.360. @see https://www.jenkins.io/doc/developer/security/csp/#legacy-javascript-checkurl-validation Signed-off-by: Kienan Stewart <kstewart@efficios.com>
1 parent c65267e commit e30f881

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/hudson/plugins/libvirt/PluginImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ public Hypervisor getServer(final String host) {
107107
}
108108

109109
@POST
110-
public FormValidation doCheckStartupWaitingPeriodSeconds(@QueryParameter String secsValue)
110+
public FormValidation doCheckStartupWaitingPeriodSeconds(@QueryParameter String value)
111111
throws IOException, ServletException {
112112
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
113113
try {
114-
int v = Integer.parseInt(secsValue);
114+
int v = Integer.parseInt(value);
115115
if (v < 0) {
116116
return FormValidation.error("Negative value..");
117117
} else if (v == 0) {
@@ -126,11 +126,11 @@ public FormValidation doCheckStartupWaitingPeriodSeconds(@QueryParameter String
126126
}
127127

128128
@POST
129-
public FormValidation doCheckStartupTimesToRetryOnFailure(@QueryParameter String retriesValue)
129+
public FormValidation doCheckStartupTimesToRetryOnFailure(@QueryParameter String value)
130130
throws IOException, ServletException {
131131
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
132132
try {
133-
int v = Integer.parseInt(retriesValue);
133+
int v = Integer.parseInt(value);
134134
if (v < 0) {
135135
return FormValidation.error("Negative value.");
136136
} else {

src/main/resources/hudson/plugins/libvirt/VirtualMachineSlave/configure-entries.jelly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
</f:entry>
4343

4444
<f:entry title="${%Startup Idle (sec)}" field="startupWaitingPeriodSeconds" help="/plugin/libvirt-slave/help-libvirt-waitingperiod.html">
45-
<f:textbox checkMethod="post" default="60" checkUrl="'${rootURL}/plugin/libvirt-slave/checkStartupWaitingPeriodSeconds?secsValue='+this.value"/>
45+
<f:textbox checkMethod="post" default="60" checkUrl="${rootURL}/plugin/libvirt-slave/checkStartupWaitingPeriodSeconds" checkDependsOn=""/>
4646
</f:entry>
4747

4848
<f:entry title="${%Times to Retry Startup}" field="startupTimesToRetryOnFailure" help="/plugin/libvirt-slave/help-libvirt-timesToRetryOnFailure.html">
49-
<f:textbox checkMethod="post" default="0" checkUrl="'${rootURL}/plugin/libvirt-slave/checkStartupTimesToRetryOnFailure?retriesValue='+this.value"/>
49+
<f:textbox checkMethod="post" default="0" checkUrl="${rootURL}/plugin/libvirt-slave/checkStartupTimesToRetryOnFailure" checkDependsOn=""/>
5050
</f:entry>
5151

5252
<f:entry title="${%# of executors}" field="numExecutors">

0 commit comments

Comments
 (0)