Skip to content

Commit

Permalink
Merge pull request #5 from jglick/JENKINS-26132-FlowNodeSerialWalker
Browse files Browse the repository at this point in the history
Load step flow graph fix
  • Loading branch information
jglick committed Apr 12, 2016
2 parents 5e8cbc2 + 934d37b commit 32c5626
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java
Expand Up @@ -35,6 +35,7 @@
import org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.cps.persistence.PersistIn;
import org.jenkinsci.plugins.workflow.cps.steps.LoadStep;
import org.jenkinsci.plugins.workflow.cps.steps.ParallelStep;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
Expand Down Expand Up @@ -114,7 +115,7 @@ public Object invokeMethod(String name, Object args) {
FlowNode an;

// TODO: generalize the notion of Step taking over the FlowNode creation.
boolean hack = d instanceof ParallelStep.DescriptorImpl;
boolean hack = d instanceof ParallelStep.DescriptorImpl || d instanceof LoadStep.DescriptorImpl;

if (ps.body == null && !hack) {
an = new StepAtomNode(exec, d, thread.head.get());
Expand Down
@@ -1,18 +1,15 @@
package org.jenkinsci.plugins.workflow.cps.steps;

import com.google.inject.Inject;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.FilePath;
import hudson.model.TaskListener;
import javax.annotation.Nonnull;
import org.jenkinsci.plugins.workflow.actions.LabelAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.cps.CpsStepContext;
import org.jenkinsci.plugins.workflow.cps.CpsThread;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl;
import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback;
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
Expand All @@ -31,9 +28,6 @@ public class LoadStepExecution extends AbstractStepExecutionImpl {
@Inject(optional=true)
private transient LoadStep step;

@StepContextParameter
private transient FlowNode node;

@StepContextParameter
private transient TaskListener listener;

Expand All @@ -51,11 +45,10 @@ public boolean start() throws Exception {

Script script = execution.getShell().parse(text);

node.addAction(new LabelAction(step.getPath()));

// execute body as another thread that shares the same head as this thread
// as the body can pause.
cps.newBodyInvoker(t.getGroup().export(script))
.withDisplayName(step.getPath())
.withCallback(BodyExecutionCallback.wrap(cps))
.start(); // when the body is done, the load step is done

Expand Down

0 comments on commit 32c5626

Please sign in to comment.