forked from jenkinsci/pipeline-graph-view-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipelineState.java
More file actions
47 lines (43 loc) · 1.21 KB
/
PipelineState.java
File metadata and controls
47 lines (43 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package io.jenkins.plugins.pipelinegraphview.utils;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Locale;
public enum PipelineState {
// BlueRunState
QUEUED,
RUNNING,
PAUSED,
SKIPPED,
NOT_BUILT,
FINISHED,
// BlueRunResult
SUCCESS,
UNSTABLE,
FAILURE,
UNKNOWN,
ABORTED;
public static PipelineState of(NodeRunStatus status) {
if (status.getState() == BlueRun.BlueRunState.FINISHED) {
return switch (status.getResult()) {
case SUCCESS -> SUCCESS;
case UNSTABLE -> UNSTABLE;
case FAILURE -> FAILURE;
case NOT_BUILT -> NOT_BUILT;
case UNKNOWN -> UNKNOWN;
case ABORTED -> ABORTED;
};
}
return switch (status.getState()) {
case QUEUED -> QUEUED;
case RUNNING -> RUNNING;
case PAUSED -> PAUSED;
case SKIPPED -> SKIPPED;
case NOT_BUILT -> NOT_BUILT;
case FINISHED -> FINISHED; // not reached but required for compiler
};
}
@JsonValue
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}