Skip to content

Instantly share code, notes, and snippets.

@eliashaeussler
Last active June 8, 2020 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliashaeussler/644177b99f9d1340bb994dffa595c291 to your computer and use it in GitHub Desktop.
Save eliashaeussler/644177b99f9d1340bb994dffa595c291 to your computer and use it in GitHub Desktop.
GitLab Omnibus version check
#!/usr/bin/env bash
## Requirements:
## * jq: https://stedolan.github.io/jq/
## * GitLab auth token: https://gitlab.example.com/profile/personal_access_tokens
GITLAB_DOMAIN="https://gitlab.example.com"
AUTH_TOKEN="<insert GitLab auth token here>"
CURRENT_VERSION="$(curl -s -H "Authorization: Bearer ${AUTH_TOKEN}" "${GITLAB_DOMAIN}/api/v4/version" | jq -r '.version')"
STABLE_VERSION="$(curl -s https://gitlab.com/api/v4/projects/13083/repository/tags | jq -r '[ .[] | .name | match("^v?(\\d+\\.\\d+\\.\\d+)$") | .captures[0].string ] | sort_by(split(".") | map(tonumber))[-1]')"
if [ "${CURRENT_VERSION}" != "${STABLE_VERSION}" ]; then
>&2 echo "A new GitLab version is available: ${STABLE_VERSION}"
>&2 echo "Current version: ${CURRENT_VERSION}"
exit 1;
fi
echo "No GitLab update available."
echo "Current version: ${CURRENT_VERSION}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment