Skip to content
Permalink
Browse files
Merge pull request #34 from svanoort/fix-issue-with-zero-branch-paral…
…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 08e75325385ddd5df825b59d8a8cc1dbf7e95f05
@@ -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
}

@@ -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();

0 comments on commit 08e7532

Please sign in to comment.