Skip to content
Permalink
Browse files

[JENKINS-43934] Verifying that flattening logic also works for symbol…

…s—we do not need to explicitly traverse UninstantiatedDescribable.
  • Loading branch information
jglick committed May 18, 2017
1 parent 5f871a4 commit c759f36ecdb31987547111e83e77d2f2b040c701
@@ -22,17 +22,18 @@
* THE SOFTWARE.
*/

package org.jenkinsci.plugins.workflow;
package org.jenkinsci.plugins.workflow.cps;

import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Result;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import static org.hamcrest.Matchers.containsString;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
@@ -114,6 +115,45 @@
}
}

@Issue("JENKINS-43934")
@Test public void flattenGString2() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo pops(pojo(/running #$BUILD_NUMBER/))", true));
r.assertLogContains("running #1", r.assertBuildStatusSuccess(p.scheduleBuild2(0)));
}
public static class Pojo extends AbstractDescribableImpl<Pojo> {
public final String x;
@DataBoundConstructor public Pojo(String x) {this.x = x;}
@Symbol("pojo")
@TestExtension("flattenGString2") public static class DescriptorImpl extends Descriptor<Pojo> {}
}
public static class Pops extends Step {
public final Pojo pojo;
@DataBoundConstructor public Pops(Pojo pojo) {this.pojo = pojo;}
@Override public StepExecution start(StepContext context) throws Exception {
return new Exec(context, pojo);
}
private static class Exec extends SynchronousStepExecution<String> {
final Pojo pojo;
Exec(StepContext context, Pojo pojo) {
super(context);
this.pojo = pojo;
}

@Override protected String run() throws Exception {
return pojo.x;
}
}
@TestExtension("flattenGString2") public static class DescriptorImpl extends StepDescriptor {
@Override public String getFunctionName() {
return "pops";
}
@Override public Set<? extends Class<?>> getRequiredContext() {
return Collections.emptySet();
}
}
}

/**
* Tests the ability to execute meta-step with clean syntax
*/
@@ -5,7 +5,7 @@
import hudson.model.Descriptor;
import hudson.model.TaskListener;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -3,7 +3,7 @@
import com.google.inject.Inject;
import hudson.Extension;
import hudson.model.TaskListener;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
@@ -3,7 +3,7 @@
import com.google.inject.Inject;
import hudson.Extension;
import hudson.model.TaskListener;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
@@ -3,7 +3,7 @@
import com.google.inject.Inject;
import hudson.Extension;
import hudson.model.TaskListener;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
@@ -3,7 +3,7 @@
import com.google.inject.Inject;
import hudson.Extension;
import hudson.model.TaskListener;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;
@@ -4,7 +4,7 @@
import hudson.model.Descriptor;
import hudson.model.TaskListener;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -5,7 +5,7 @@
import hudson.model.Descriptor;
import hudson.model.TaskListener;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

@@ -2,7 +2,7 @@

import hudson.model.AbstractDescribableImpl;
import hudson.model.TaskListener;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;

/**
* @author Kohsuke Kawaguchi
@@ -5,7 +5,7 @@
import hudson.model.TaskListener;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.structs.SymbolLookup;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.cps.DSLTest;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution;

0 comments on commit c759f36

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