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

Fix incorrect step result when referencing an ErrorAction #353

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.jenkins.plugins.pipelinegraphview.utils;

import hudson.model.Result;

public class BlueRun {
public enum BlueRunState {
QUEUED,
Expand Down Expand Up @@ -28,6 +30,22 @@
UNKNOWN,

/** Aborted run */
ABORTED,
ABORTED;

public static BlueRunResult fromResult(Result result) {
if (result == Result.SUCCESS) {

Check warning on line 36 in src/main/java/io/jenkins/plugins/pipelinegraphview/utils/BlueRun.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 36 is only partially covered, one branch is missing
return BlueRunResult.SUCCESS;

Check warning on line 37 in src/main/java/io/jenkins/plugins/pipelinegraphview/utils/BlueRun.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 37 is not covered by tests
} else if (result == Result.UNSTABLE) {
return BlueRunResult.UNSTABLE;
} else if (result == Result.FAILURE) {

Check warning on line 40 in src/main/java/io/jenkins/plugins/pipelinegraphview/utils/BlueRun.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 40 is only partially covered, one branch is missing
return BlueRunResult.FAILURE;
} else if (result == Result.NOT_BUILT) {
return BlueRunResult.NOT_BUILT;
} else if (result == Result.ABORTED) {
return BlueRunResult.ABORTED;
} else {
return BlueRunResult.UNKNOWN;

Check warning on line 47 in src/main/java/io/jenkins/plugins/pipelinegraphview/utils/BlueRun.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 42-47 are not covered by tests
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ public class NodeRunStatus {
public final BlueRun.BlueRunState state;

public NodeRunStatus(@NonNull FlowNode endNode) {
Result result = null;
ErrorAction errorAction = endNode.getError();
WarningAction warningAction = endNode.getPersistentAction(WarningAction.class);
if (errorAction != null) {
Result result = null;
if (errorAction.getError() instanceof FlowInterruptedException) {
result = ((FlowInterruptedException) errorAction.getError()).getResult();
}
if (result == null || result != Result.ABORTED) {
this.result = BlueRun.BlueRunResult.FAILURE;
} else {
this.result = BlueRun.BlueRunResult.ABORTED;
}
this.result = result != null ? BlueRun.BlueRunResult.fromResult(result) : BlueRun.BlueRunResult.FAILURE;
this.state = endNode.isActive() ? BlueRun.BlueRunState.RUNNING : BlueRun.BlueRunState.FINISHED;
} else if (warningAction != null) {
this.result = new NodeRunStatus(GenericStatus.fromResult(warningAction.getResult())).result;
this.result = BlueRun.BlueRunResult.fromResult(warningAction.getResult());
this.state = endNode.isActive() ? BlueRun.BlueRunState.RUNNING : BlueRun.BlueRunState.FINISHED;
} else if (QueueItemAction.getNodeState(endNode) == QueueItemAction.QueueState.QUEUED) {
this.result = BlueRun.BlueRunResult.UNKNOWN;
Expand Down