Skip to content

Commit

Permalink
[FIXED JENKINS-28222] Branch labels were being incorrectly skipped af…
Browse files Browse the repository at this point in the history
…ter an end block node.
  • Loading branch information
jglick committed Sep 13, 2016
1 parent 86e4b06 commit 1f24b2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Expand Up @@ -427,12 +427,14 @@ private long writeRawLogTo(AnnotatedLargeText<?> text, long start, OutputStream
@GuardedBy("completed")
private transient LoadingCache<FlowNode,Optional<String>> logPrefixCache;
private @CheckForNull String getLogPrefix(FlowNode node) {
// TODO could also use FlowScanningUtils.fetchEnclosingBlocks(node).filter(FlowScanningUtils.hasActionPredicate(ThreadNameAction.class)),
// but this would not let us cache intermediate results
synchronized (completed) {
if (logPrefixCache == null) {
logPrefixCache = CacheBuilder.newBuilder().weakKeys().build(new CacheLoader<FlowNode,Optional<String>>() {
@Override public @Nonnull Optional<String> load(FlowNode node) {
if (node instanceof BlockEndNode) {
return Optional.absent();
return Optional.fromNullable(getLogPrefix(((BlockEndNode) node).getStartNode()));
}
ThreadNameAction threadNameAction = node.getAction(ThreadNameAction.class);
if (threadNameAction != null) {
Expand Down
Expand Up @@ -54,8 +54,6 @@
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import static org.junit.Assert.*;
import org.junit.ClassRule;
Expand Down Expand Up @@ -276,4 +274,31 @@ public void failedToStartRun() throws Exception {
assertEquals(Collections.emptyList(), iba.getCauses());
}

@Test
@Issue({"JENKINS-26122", "JENKINS-28222"})
public void parallelBranchLabels() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"parallel a: {\n" +
" echo 'a-outside-1'\n" +
" withEnv(['A=1']) {echo 'a-inside-1'}\n" +
" echo 'a-outside-2'\n" +
" withEnv(['A=1']) {echo 'a-inside-2'}\n" +
"}, b: {\n" +
" echo 'b-outside-1'\n" +
" withEnv(['B=1']) {echo 'b-inside-1'}\n" +
" echo 'b-outside-2'\n" +
" withEnv(['B=1']) {echo 'b-inside-2'}\n" +
"}", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
r.assertLogContains("[a] a-outside-1", b);
r.assertLogContains("[b] b-outside-1", b);
r.assertLogContains("[a] a-inside-1", b);
r.assertLogContains("[b] b-inside-1", b);
r.assertLogContains("[a] a-outside-2", b);
r.assertLogContains("[b] b-outside-2", b);
r.assertLogContains("[a] a-inside-2", b);
r.assertLogContains("[b] b-inside-2", b);
}

}

0 comments on commit 1f24b2e

Please sign in to comment.