Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #38 from jenkinsci/fix-incomplete-parallel-final-o…
…rder

Fix finding the end of the fhinal chunk in the presence of incomplete parallel branches [JENKINS-38536]
  • Loading branch information
svanoort committed Mar 6, 2017
2 parents 0045b78 + 855a87e commit ead4a5d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rest-api/pom.xml
Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.4</version> <!-- allows consuming the new APIs -->
<version>2.12</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Expand Up @@ -35,6 +35,7 @@ public class ChunkVisitor extends StandardChunkVisitor {
ArrayDeque<AtomFlowNodeExt> stageContents = new ArrayDeque<AtomFlowNodeExt>();
WorkflowRun run;
ArrayList<String> stageNodeIds = new ArrayList<String>();
boolean isLastChunk = true;

public ChunkVisitor(@Nonnull WorkflowRun run) {
this.run = run;
Expand Down Expand Up @@ -156,4 +157,14 @@ public void atomNode(@CheckForNull FlowNode before, @Nonnull FlowNode atomNode,
}
stageNodeIds.add(atomNode.getId());
}

@Override
public void parallelEnd(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode parallelEndNode, @Nonnull ForkScanner scanner) {
if (isLastChunk) {
// Filthy hack, but for incomplete parallels, we use this event to reset the chunk boundaries
// This works around issues due to branches being visited in order DECLARED, not TIME-ordered
chunk.setLastNode(parallelEndNode);
}
isLastChunk = false;
}
}
Expand Up @@ -23,8 +23,11 @@
*/
package com.cloudbees.workflow.rest.external;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.jenkinsci.plugins.workflow.actions.ErrorAction;

import javax.annotation.Nonnull;

/**
* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
Expand All @@ -49,12 +52,8 @@ public void setType(String type) {
this.type = type;
}


public static ErrorExt create(ErrorAction errorAction) {
if (errorAction == null) {
return null;
}

@SuppressFBWarnings(value="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification="Serialization can cause forbidden null")
public static ErrorExt create(@Nonnull ErrorAction errorAction) {
ErrorExt errorExt = new ErrorExt();
Throwable throwable = errorAction.getError();

Expand Down
Expand Up @@ -242,7 +242,8 @@ private void assertTimingHandlesBuggyFlowEndNode(WorkflowJob job, JenkinsRule.We
TimingAction timing = lastNode.getAction(TimingAction.class);

// Remove timing info from last node (root cause of one set of bugs) and flush the cache
actions.remove(timing);
int timingIndex = actions.indexOf(timing);
actions.remove(timingIndex);
FlowNodeUtil.CacheExtension ext = FlowNodeUtil.CacheExtension.all().get(0);
ext.getRunCache().invalidateAll();

Expand Down

0 comments on commit ead4a5d

Please sign in to comment.