Skip to content

Commit

Permalink
Merge pull request #255 from jglick/ChoiceParameterDefinition-JENKINS…
Browse files Browse the repository at this point in the history
…-53917

[JENKINS-53917] DescribableModel again treating ChoiceParameterDefinition.choices as an object
  • Loading branch information
jglick committed Oct 5, 2018
2 parents c71db05 + 5910a72 commit a67af1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<workflow-support-plugin.version>2.21-beta-1</workflow-support-plugin.version>
<scm-api-plugin.version>2.2.6</scm-api-plugin.version>
<groovy-cps.version>1.24</groovy-cps.version>
<structs-plugin.version>1.16</structs-plugin.version>
<structs-plugin.version>1.17</structs-plugin.version>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.JenkinsRule;

import javax.annotation.CheckForNull;
Expand All @@ -35,7 +32,6 @@
import java.util.Map;

import org.jenkinsci.plugins.workflow.util.StaplerReferer;
import org.kohsuke.stapler.NoStaplerConstructorException;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -132,16 +128,21 @@ public static void assertDocGeneration(Class<? extends Describable> describableC

}

private static void recurseOnTypes(ParameterType type) throws Exception {
private static void recurseOnTypes(DescribableModel<?> model, ParameterType type) throws Exception {
if (type instanceof ErrorType) {
throw ((ErrorType)type).getError();
throw new Exception("could not describe " + model, ((ErrorType) type).getError());
}

if (type instanceof ArrayType) {
recurseOnTypes(((ArrayType)type).getElementType());
recurseOnTypes(model, ((ArrayType)type).getElementType());
} else if (type instanceof HomogeneousObjectType) {
recurseOnModel(((HomogeneousObjectType) type).getSchemaType());
} else if (type instanceof HeterogeneousObjectType) {
if (((HeterogeneousObjectType) type).getActualType() == Object.class) {
// See html.groovy#describeType. For example, JENKINS-53917 ChoiceParameterDefinition.choices.
System.err.println("Ignoring " + model.getType().getName() + " since a parameter is not enumerable");
return;
}
for (Map.Entry<String, DescribableModel<?>> entry : ((HeterogeneousObjectType) type).getTypes().entrySet()) {
recurseOnModel(entry.getValue());
}
Expand All @@ -150,7 +151,7 @@ private static void recurseOnTypes(ParameterType type) throws Exception {

private static void recurseOnModel(DescribableModel<?> model) throws Exception {
for (DescribableParameter param : model.getParameters()) {
recurseOnTypes(param.getType());
recurseOnTypes(model, param.getType());
}
}

Expand Down

0 comments on commit a67af1d

Please sign in to comment.