diff --git a/README.md b/README.md index 3b3f701..17cc1ee 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Actually only used by the html endpoint. ## prometheus Endpoint: `/api/adapter/prometheus` -Can be used as exporter from a prometheus scraper. Return values are: success=0, skipped=1, canceled=2, failed=10. +Can be used as exporter from a prometheus scraper. Return values are: success=0, skipped=1, canceled=2, manual=3, failed=10. Examples: diff --git a/src/main/java/de/joblift/service/gitlabpanorama/core/models/Status.java b/src/main/java/de/joblift/service/gitlabpanorama/core/models/Status.java index 9d79e61..7f70eb8 100644 --- a/src/main/java/de/joblift/service/gitlabpanorama/core/models/Status.java +++ b/src/main/java/de/joblift/service/gitlabpanorama/core/models/Status.java @@ -11,6 +11,7 @@ public enum Status { // sleeping success, + manual, failed, canceled, skipped; diff --git a/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/bashboard/ShellResource.java b/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/bashboard/ShellResource.java index bb873f7..43ea504 100644 --- a/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/bashboard/ShellResource.java +++ b/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/bashboard/ShellResource.java @@ -61,7 +61,8 @@ public String shell(@RequestParam(defaultValue = "true") Boolean dots, String stringFailures = list(pipelines, Status.failed, delimiterProjects, refs, filterStatusList); String stringSkipped = list(pipelines, Status.skipped, delimiterProjects, refs, filterStatusList); String stringSuccess = list(pipelines, Status.success, delimiterProjects, refs, filterStatusList); - builder.append(Joiner.on(delimiterLists).skipNulls().join(stringFailures, stringSkipped, stringSuccess)); + String stringManual = list(pipelines, Status.manual, delimiterProjects, refs, filterStatusList); + builder.append(Joiner.on(delimiterLists).skipNulls().join(stringFailures, stringSkipped, stringSuccess, stringManual)); } return builder.toString(); @@ -100,6 +101,9 @@ private Color getLastBuildStatus(PipelinePair pair) { if (pair.getCurrent().getStatus() == Status.skipped) { return Color.WHITE; } + if (pair.getCurrent().getStatus() == Status.manual) { + return Color.CYAN; + } return Color.MAGENTA; } diff --git a/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/ccmenu/CcmenuResource.java b/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/ccmenu/CcmenuResource.java index bb87954..a5dce04 100644 --- a/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/ccmenu/CcmenuResource.java +++ b/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/ccmenu/CcmenuResource.java @@ -98,10 +98,13 @@ private String getLastBuildStatus(PipelinePair pair) { if (pair.getCurrent().getStatus() == Status.failed) { return "Failure"; } - // ccmenu does not reflect skipped, show as success since it is at least not failed + // ccmenu does not reflect skipped or manual, show as success since it is at least not failed if (pair.getCurrent().getStatus() == Status.skipped) { return "Success"; } + if (pair.getCurrent().getStatus() == Status.manual) { + return "Success"; + } return "Unknown"; } diff --git a/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/prometheus/PrometheusExporter.java b/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/prometheus/PrometheusExporter.java index 981f49b..a4cf1ce 100644 --- a/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/prometheus/PrometheusExporter.java +++ b/src/main/java/de/joblift/service/gitlabpanorama/resources/adapter/prometheus/PrometheusExporter.java @@ -43,6 +43,8 @@ protected String stateToValue(PipelinePair pair) { return "1"; case canceled: return "2"; + case manual: + return "3"; case failed: return "10"; default: diff --git a/src/test/java/de/joblift/service/gitlabpanorama/core/aggregator/PipelinePairTest.java b/src/test/java/de/joblift/service/gitlabpanorama/core/aggregator/PipelinePairTest.java index 6c6498a..0d3e0c6 100644 --- a/src/test/java/de/joblift/service/gitlabpanorama/core/aggregator/PipelinePairTest.java +++ b/src/test/java/de/joblift/service/gitlabpanorama/core/aggregator/PipelinePairTest.java @@ -1,15 +1,14 @@ package de.joblift.service.gitlabpanorama.core.aggregator; -import static de.galan.commons.time.Instants.*; -import static org.assertj.core.api.Assertions.*; - -import java.time.Instant; - -import org.junit.jupiter.api.Test; - import de.joblift.service.gitlabpanorama.core.models.Pipeline; import de.joblift.service.gitlabpanorama.core.models.Project; import de.joblift.service.gitlabpanorama.core.models.Status; +import org.junit.jupiter.api.Test; + +import java.time.Instant; + +import static de.galan.commons.time.Instants.instantUtc; +import static org.assertj.core.api.Assertions.assertThat; /** @@ -49,6 +48,14 @@ public void singleActiveAndCurrent() { assertThat(pp.getCurrent()).isEqualTo(pc); } + @Test + public void singleManual() { + Pipeline p = p(1L, Status.manual); + PipelinePair pp = new PipelinePair(p); + assertThat(pp.getActive()).isNull(); + assertThat(pp.getCurrent()).isEqualTo(p); + } + @Test public void currentFailedSucceeded() { @@ -104,6 +111,15 @@ public void currentSuccessFromRetry() { assertThat(pp.getCurrent()).isEqualTo(pc2); } + @Test + public void currentActiveFromManual() { + Pipeline pc = p(1L, Status.manual, T1); + Pipeline pa = p(1L, Status.running, T2); + PipelinePair pp = new PipelinePair(pa, pc); + assertThat(pp.getActive()).isEqualTo(pa); + assertThat(pp.getCurrent()).isEqualTo(pc); + } + @Test public void retrySuccess() {