marcells / node-build-monitor

A Build Monitor written in Node.js, which supports several build services and can be easily extended.
https://marcells.github.io/node-build-monitor
MIT License
349 stars 168 forks source link

How backgroundcolor depends on state of gitlab-pipeline #228

Closed ehmkah closed 3 years ago

ehmkah commented 3 years ago

I am not quite sure how the color in the overview depends on the state of the gitlab pipeline;

The obvious ones are: green => pipeline is green red => pipeline is red grey => pipeline canceled blue => pipeline running

But if a pipeline is passed with warnings it seems for me that the color is green but I would prefer that it is yellow. Is that possible? We have pipelines which have warnings and those need further investigations.

ehmkah commented 3 years ago

Seems to be not possible with gitlab because there is only one state for "success" and "success with warning" (https://docs.gitlab.com/ee/api/pipelines.html#list-project-pipelines)

Gitlab has a feature request which wants "warning" state https://gitlab.com/gitlab-org/gitlab/-/issues/229137

marcells commented 3 years ago

Did you take a look at this comment? Maybe this could be a solution.

https://gitlab.com/gitlab-org/gitlab/-/issues/229137#note_388855588

ehmkah commented 3 years ago

okay interesting - i will have a look, maybe thats interesting. our plan was to add a last job which will fail :-)

ehmkah commented 3 years ago

With the URI api/v4/projects/<PROJECT_ID>/pipelines/<PIPELINE_ID> If I receive something which might be of use.

...<removed_information_not_required_for_the_issue>...
  "detailed_status": {
    "icon": "status_warning",
    "text": "passed",
    "label": "passed with warnings",
    "group": "success-with-warnings",
    "tooltip": "passed",
    "has_details": false,
    "details_path": "/replaceWithFOooByMe/pipelines/1234567",
    "illustration": null,
    "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"
  }

@marcells - can that be used for determing the state of the last pipeline? is there a value in node-build-monitor for "warning"?

marcells commented 3 years ago

Yes, you can use the hasWarnings flag (bool). I don't use GitLab or have experience with it, but I think that this request could do the trick.

Here is a sample of the return value of the Tfs service:

let result = {
        definition: build.definition.name,
        finishedAt: build.finishTime ? new Date(build.finishTime) : '',
        hasErrors: build.result === resultFilter.failed,
        hasWarnings: build.result === resultFilter.partiallySucceeded,
        id: build.id,
        isRunning: build.status === statusFilter.inProgress,
        isQueued: build.status === statusFilter.notStarted,
        number: build.buildNumber,
        project: getProjectName(build),
        queuedAt: build.queueTime ? new Date(build.queueTime) : new Date(),
        reason: build.reason,
        requestedFor: build.requestedFor ? build.requestedFor.displayName : '',
        startedAt: new Date(build.startTime),
        status: color,
        statusText: text,
        timeline: build._links.timeline ? build._links.timeline.href : '',
        url: webUrl
      };

Feel free to make a PR.

ehmkah commented 3 years ago

Pullrequest https://github.com/marcells/node-build-monitor/pull/231 is open - I am happy waiting for your comments. Maybe storing color values for success, warning, running, etc should be managed as global constant. I copied the value from the jenkins-service-implementation.

marcells commented 3 years ago

I'm fine with that. As long as all color values are kept in the getBuildStatus method we don't need to move them somewhere. But if you want to, then do it. ;-)

ehmkah commented 3 years ago

For the colors I opened a new issue https://github.com/marcells/node-build-monitor/issues/232

marcells commented 3 years ago

Ah, I see, how you ment it. That's a good idea. 👍