Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #265 from jglick/parallel-JENKINS-29413
[JENKINS-29413] Hung build when running the parallel step with an empty map
  • Loading branch information
jglick committed Dec 6, 2015
2 parents be558db + 1ecc56e commit 85330f6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -2,6 +2,10 @@

Only noting significant user changes, not internal code cleanups and minor bug fixes.

## 1.12 (upcoming)

* [JENKINS-29413](https://issues.jenkins-ci.org/browse/JENKINS-29413): hung build when running the `parallel` step with an empty map.

## 1.12-beta-2 (Nov 25 2015)

* [JENKINS-29705](https://issues.jenkins-ci.org/browse/JENKINS-29705): added _Thread Dump_ link to running flow builds for diagnosing problems like hangs.
Expand Down
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 85330f6

Please sign in to comment.