Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get build status from GitLab CI?

Tags:

gitlab

I want to add in cap deploy scenario checking build status from GitLab CI.

Is it possible?

Does GitLab CI has some API to get build/pipeline status by commit SHA?

like image 559
Alexey Avatar asked Mar 11 '13 15:03

Alexey


5 Answers

You can find the build badge information on the Pipelines settings page, that is

https://<your-gitlab-installation-domain>/<group-name>/<repository-name>/settings/ci_cd

For a specific repository:

  1. go to Settings > CI / CD
  2. expand the General pipelines settings section
  3. scroll down to Pipeline status and/or Coverage report
  4. select your branch
  5. copy whatever you need (Markdown, perhaps)

For reference, see:

  • https://docs.gitlab.com/ee/ci/pipelines.html#badges
  • https://docs.gitlab.com/ee/user/project/pipelines/settings.html
like image 75
localheinz Avatar answered Oct 19 '22 19:10

localheinz


Now you can get the badge from this url:

https://gitlab.com/[namespace]/[project]/badges/[branch]/pipeline.svg
like image 30
Ankit R Gadiya Avatar answered Oct 19 '22 20:10

Ankit R Gadiya


API

Since GitLab 8.1, there is the new commit status API.

GitLab CI Commits API v4:

List the statuses of a commit

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/statuses

P.s. GitLabs tokens are being managed in the Personal Access Tokens page (https://gitlab.example.com/profile/personal_access_tokens)

glab and lab

There are two great tools to work with GitLab:

  • zaquestion/lab: Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab profclems/glab: An open-source GitLab command line tool bringing GitLab's cool features to your command line

Both glab and lab are open-source tools with the same goal of bringing GitLab to your command line and simplifying the developer workflow. In many ways lab is to hub, what glab is to gh.

lab aims to feel familiar to a git user and leverages git to power many of it's commands. glab will feel more familiar to gh users and in turn is more interactive and likely more beginner friendly for that reason.

lab ci status

For textual representation of a CI pipeline with lab you may want:

lab ci status [branch] [flags]

Examples

lab ci status
lab ci status upstream 608 --merge-request
lab ci status 600 --wait
lab ci status upstream 125 --merge-request --bridge 'security-tests'

glab pipeline status

For textual representation of a CI pipeline with glab you may want:

glab pipeline status \[flags\]

Examples

$ glab pipeline status --live
$ glab pipeline status --branch=master   // Get pipeline for master branch
$ glab pipe status   // Get pipeline for current branch
like image 23
Yasen Avatar answered Oct 19 '22 21:10

Yasen


GitLab CI is based on Travis, which provide build status url and even build status picture:

https://travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME].png
# or, limited to some branches
https://travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME].png?branch=master,staging,production

Joran Beasley mentions the url:

http://gitlabci.example.com/projects/2/status.png?ref=master
like image 45
VonC Avatar answered Oct 19 '22 19:10

VonC


I have found such link http://some.domain/projects/:ID/builds/:SHA/status . Problem resolved

like image 5
Alexey Avatar answered Oct 19 '22 20:10

Alexey