Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-53917] DescribableModel again treating ChoiceParameterDefinition.choices as an object #255

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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