Last active
June 11, 2019 08:16
-
-
Save fqxp/c65f96f372344a7b26c99e5ebc2b71b0 to your computer and use it in GitHub Desktop.
gitlab-pipeline-status: outputs status of last build pipeline from gitlab (install and configure gitlab CLI from https://github.com/NARKOZ/gitlab/ first)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if ! git status >/dev/null 2>&1 ; then | |
echo "not a git repository" | |
exit 1 | |
fi | |
PROJECT_NAME=$(git remote get-url origin | sed 's#.*:\(.*\)\.git#\1#') | |
BRANCH=$(git branch|grep '^\*'|cut -d\ -f2) | |
PIPELINE_SUCCESS=$(gitlab pipelines $PROJECT_NAME "{ per_page: 100 }" | grep $BRANCH | head -1 | cut -d\| -f 5) | |
if [ -z "$PIPELINE_SUCCESS" ] ; then | |
echo none | |
else | |
echo $PIPELINE_SUCCESS | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment