A super simple bash script to check the status of a GitLab CI pipeline.
$ git push
...
$ git pipeline-status
Status of last pipeline for user/project on gitlab/master:
"pending"
...
$ git pipeline-status
Status of last pipeline for user/project on gitlab/master:
"running"
...
$ git pipeline-status
Status of last pipeline for user/project on gitlab/master:
"success"
Aside from git
and curl
, you will need jq
(see https://stedolan.github.io/jq/, or just brew install jq
).
Your GitLab private access token needs to be set in an environment variable called GITLAB_API_PRIVATE_TOKEN
.
Your GitLab remote needs to be named either gitlab
or origin
. If it's not, you can override those via the GITLAB_REMOTE
environment variable.
~/bin
needs to be in your $PATH
- Copy the attached
git-pipeline-status
into your~/bin
directory - Make it executable:
chmod +x ~/bin/git-pipeline-status
git pipeline-status
"How does putting a random script in my ~/bin
make this work?" See git source and this coderwall blog post
Thanks! One thing ..was getting error:
jq parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 2, column 1
So updated last line:
echo $JSON | tr '\r\n' ' ' | jq .last_pipeline.status