Skip to content

Instantly share code, notes, and snippets.

@fqxp
Last active June 11, 2019 08:16
Show Gist options
  • Save fqxp/c65f96f372344a7b26c99e5ebc2b71b0 to your computer and use it in GitHub Desktop.
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)
#!/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