Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-50199] Fix cases where builds would "resume" even though the execution is complete #104

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions pom.xml
Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.25</version>
<version>2.27</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand All @@ -92,19 +92,19 @@
<!-- Satisfy upper bound dependencies -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.39</version>
<version>1.42</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.43</version>
<version>2.54</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.10</version>
<version>1.14</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -132,6 +132,12 @@
<version>2.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-input-step</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SemaphoreStep instead.

<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
Expand Down
Expand Up @@ -874,10 +874,24 @@ private void finish(@Nonnull Result r, @CheckForNull Throwable t) {
}
fetchedExecution.onLoad(new Owner(this));
if (this.completed != Boolean.TRUE) {
// Defer the normal listener to ensure onLoad can complete before finish() is called since that may
// need the build to be loaded and can result in loading loops otherwise.
fetchedExecution.removeListener(finishListener);
fetchedExecution.addListener(new GraphL());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: minor merge conflict with #27.

if (fetchedExecution.isComplete()) { // See JENKINS-50199 for cases where the execution is marked complete but build is not
// Somehow arrived at one of those weird states
LOGGER.log(Level.WARNING, "Found incomplete build with completed execution - display name: "+this.getFullDisplayName());
this.completed = true;
Result finalResult = Result.FAILURE;
List<FlowNode> heads = fetchedExecution.getCurrentHeads();
if (!heads.isEmpty() && heads.get(0) instanceof FlowEndNode) {
finalResult = ((FlowEndNode)(heads.get(0))).getResult();
}
setResult(finalResult);
fetchedExecution.removeListener(finishListener);
saveWithoutFailing();
} else {
// Defer the normal listener to ensure onLoad can complete before finish() is called since that may
// need the build to be loaded and can result in loading loops otherwise.
fetchedExecution.removeListener(finishListener);
fetchedExecution.addListener(new GraphL());
}
}
SettableFuture<FlowExecution> settablePromise = getSettableExecutionPromise();
if (!settablePromise.isDone()) {
Expand Down