Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-29413]: hung build when running the parallel step with…
… an empty map.

Originally-Committed-As: 1ecc56e967940fbc6047aa432d5d5e556670eca2
  • Loading branch information
jglick committed Dec 4, 2015
1 parent 627d6f1 commit bd606c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Expand Up @@ -401,6 +401,17 @@ public void invisibleParallelBranch() throws Exception {
});
}

@Issue("JENKINS-29413")
@Test public void emptyMap() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
p = jenkins().createProject(WorkflowJob.class, "demo");
p.setDefinition(new CpsFlowDefinition("parallel [:]", true));
story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
}
});
}

@Test
@Issue("JENKINS-26122")
public void parallelBranchLabels() {
Expand Down
@@ -1,6 +1,7 @@
package org.jenkinsci.plugins.workflow.cps.steps;

import groovy.lang.Closure;
import hudson.model.TaskListener;
import org.jenkinsci.plugins.workflow.actions.LabelAction;
import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
import org.jenkinsci.plugins.workflow.cps.CpsStepContext;
Expand All @@ -13,6 +14,7 @@

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;

Expand All @@ -37,6 +39,12 @@ public ParallelStepExecution(ParallelStep parallelStep, StepContext context) {
@Override
public boolean start() throws Exception {
CpsStepContext cps = (CpsStepContext) getContext();
if (parallelStep.closures.isEmpty()) {
cps.get(TaskListener.class).getLogger().println("No branches to run");
cps.onSuccess(Collections.<String,Object>emptyMap());
return true;
}

CpsThread t = CpsThread.current();

ResultHandler r = new ResultHandler(cps, this, parallelStep.isFailFast());
Expand Down

0 comments on commit bd606c2

Please sign in to comment.