Skip to content

Commit

Permalink
Merge pull request #34 from svanoort/fix-issue-with-zero-branch-paral…
Browse files Browse the repository at this point in the history
…lels-JENKINS-42895

Fix a ForkScanner sanity check failing with a specific case of zero-branch parallels [JENKINS-42895]
  • Loading branch information
svanoort committed Apr 13, 2017
2 parents b340047 + 1dc1d64 commit 08e7532
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Expand Up @@ -550,9 +550,7 @@ FlowNode hitParallelStart() {
}
}
} else {
if (isWalkingFromFinish()) { //Incomplete single-branch parallels can do this
throw new IllegalStateException("Hit a BlockStartNode with no record of the start!");
}
// Incomplete single-branch parallel, or worse, a 0-branch parallel
return myCurrent.getParents().get(0); // No branches to explore
}

Expand Down
Expand Up @@ -661,6 +661,33 @@ public void testVariousParallelCombos() throws Exception {
}
}

@Test
@Issue("JENKINS-42895")
public void testMissingHeadErrorWithZeroBranchParallel() throws Exception {
WorkflowJob job = r.jenkins.createProject(WorkflowJob.class, "MissingHeadBug");
job.setDefinition(new CpsFlowDefinition("" +
"stage('Stage A') {\n" +
" echo \"A\"\n" +
"}\n" +
"// Works\n" +
"stage('Stage B') {\n" +
" parallel a: {\n" +
" echo \"B.A\"\n" +
" }, b: {\n" +
" echo \"B.B\"\n" +
" }\n" +
"}\n" +
"// Breaks\n" +
"stage('Stage C') {\n" +
" def steps = [:]\n" +
" // Empty map\n" +
" parallel steps\n" +
"}\n"));
WorkflowRun run = r.buildAndAssertSuccess(job);
FlowExecution exec = run.getExecution();
sanityTestIterationAndVisiter(exec.getCurrentHeads());
}

@Test
public void testParallelPredicate() throws Exception {
FlowExecution exec = SIMPLE_PARALLEL_RUN.getExecution();
Expand Down

0 comments on commit 08e7532

Please sign in to comment.