Skip to content
Permalink
Browse files

[FIX JENKINS-39700] Don't fail when no parameters property for job

  • Loading branch information...
daniel-beck committed Dec 9, 2016
1 parent 9172bca commit e43222dde84be0ea7d05647790fedc12d70f8052
Showing with 0 additions and 16 deletions.
  1. +0 −16 core/src/main/java/hudson/model/Job.java
@@ -1231,8 +1231,6 @@ public synchronized void doConfigSubmit(StaplerRequest req,
DescribableList<JobProperty<?>, JobPropertyDescriptor> t = new DescribableList<JobProperty<?>, JobPropertyDescriptor>(NOOP,getAllProperties());
JSONObject jsonProperties = json.optJSONObject("properties");
if (jsonProperties != null) {
//This handles the situation when Parameterized build checkbox is checked but no parameters are selected. User will be redirected to an error page with proper error message.
Job.checkForEmptyParameters(jsonProperties);
t.rebuild(req,jsonProperties,JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass()));
} else {
t.clear();
@@ -1537,18 +1535,4 @@ public BuildTimelineWidget getTimeline() {
}

private final static HexStringConfidentialKey SERVER_COOKIE = new HexStringConfidentialKey(Job.class,"serverCookie",16);

/**
* This handles the situation when Parameterized build checkbox is checked
* but no parameters are selected. User will be redirected to an error page
* with proper error message.
* @param jsonProperties
* @throws FormException
*/
private static void checkForEmptyParameters(JSONObject jsonProperties) throws FormException{
JSONObject parameterDefinitionProperty = jsonProperties.getJSONObject("hudson-model-ParametersDefinitionProperty");
if ((parameterDefinitionProperty.getBoolean("specified") == true)&& !parameterDefinitionProperty.has("parameterDefinitions")) {
throw new FormException(Messages.Hudson_NoParamsSpecified(),"parameterDefinitions");
}
}
}

0 comments on commit e43222d

Please sign in to comment.
You can’t perform that action at this time.