From 4d8f435bacf858dc1243014aad518376382720cc Mon Sep 17 00:00:00 2001 From: Mark McDonnell Date: Mon, 4 Apr 2016 14:15:12 +0100 Subject: [PATCH] Create ci-git-tag-compared-to-release.sh --- ci-git-tag-compared-to-release.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ci-git-tag-compared-to-release.sh diff --git a/ci-git-tag-compared-to-release.sh b/ci-git-tag-compared-to-release.sh new file mode 100644 index 0000000..35a2ecc --- /dev/null +++ b/ci-git-tag-compared-to-release.sh @@ -0,0 +1,28 @@ +latest_release=$(curl \ + --cert /etc/pki/tls/certs/client.crt \ + --key /etc/pki/tls/private/client.key \ + --header 'Content-Type: application/json' \ + --silent \ + https://my.api.com/component/foo/releases | \ + grep -Eo '"version": "[[:digit:]]+' | \ + cut -d : -f 2 | \ + cut -d '"' -f 2 | \ + head -n 1) + +tag=$(git tag | tail -n 1) + +if [ $tag -le $latest_release ]; then + echo 1 > status + echo "The latest tag ($tag) is less than, or equal to, the latest release ($latest_release) so no point in building a new release" + exit +fi + +echo "DO STUFF" + +# In another Jenkins shell block... + +if [ $(cat status) -eq 1 ]; then + exit +fi + +echo "OTHERWISE DO STUFF"