Skip to content

Commit

Permalink
[JENKINS-44981] Add GenericStatus.QUEUED and related logic
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Jun 21, 2017
1 parent 92c9ba3 commit 63fd837
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 62 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -52,12 +52,12 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.17</version>
<version>2.18-20170620.195845-2</version> <!-- TODO: update to release when https://github.com/jenkinsci/workflow-api-plugin/pull/42 is merged and released -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.17</version>
<version>2.18-20170620.195845-2</version> <!-- TODO: update to release when https://github.com/jenkinsci/workflow-api-plugin/pull/42 is merged and released -->
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
Expand Down Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.5</version>
<version>2.13-20170621.145853-1</version> <!-- TODO: Switch to release once https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/42 is merged and released -->
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Expand Up @@ -45,6 +45,11 @@ public enum GenericStatus {
*/
UNSTABLE,

/**
* Not complete: still executing, in a node block, but the node block is in queue.
*/
QUEUED,

/**
* Not complete: still executing, waiting for a result
*/
Expand Down
Expand Up @@ -32,9 +32,11 @@
import hudson.model.Result;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.workflow.actions.ErrorAction;
import org.jenkinsci.plugins.workflow.actions.ExecutorTaskInfoAction;
import org.jenkinsci.plugins.workflow.actions.NotExecutedNodeAction;
import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
import org.jenkinsci.plugins.workflow.actions.TimingAction;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
Expand Down Expand Up @@ -172,10 +174,27 @@ public static GenericStatus computeChunkStatus(@Nonnull WorkflowRun run,
return (lastNode.getError() == null) ? GenericStatus.SUCCESS : GenericStatus.FAILURE;
}
}

if (lastNode instanceof StepStartNode) {
ExecutorTaskInfoAction execAction = lastNode.getAction(ExecutorTaskInfoAction.class);
if (execAction != null) {
if (execAction.isQueued()) {
return GenericStatus.QUEUED;
} else if (execAction.isCanceled()) {
return GenericStatus.ABORTED;
} else {
return GenericStatus.IN_PROGRESS;
}
}
}

PauseAction pauseAction = lastNode.getAction(PauseAction.class);
return (isPendingInput(run) &&
pauseAction != null && pauseAction.getCause().equals("Input"))
? GenericStatus.PAUSED_PENDING_INPUT : GenericStatus.IN_PROGRESS;
if (isPendingInput(run) &&
pauseAction != null && pauseAction.getCause().equals("Input")) {
return GenericStatus.PAUSED_PENDING_INPUT;
} else {
return GenericStatus.IN_PROGRESS;
}
} else {
// Final chunk on completed build
Result r = run.getResult();
Expand Down

0 comments on commit 63fd837

Please sign in to comment.