Skip to content

Commit 5cab576

Browse files
committed
Adds logic to tag release to skip tagging if one already exists
1 parent a50cf6c commit 5cab576

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Jenkinsfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@ spec:
208208
set -x
209209
set -e
210210
211+
echo "IMAGE_NAME=$(basename -s .git `git config --get remote.origin.url` | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')" > ./env-config
212+
213+
if [[ "${BRANCH}" == "master" ]] && [[ $(git describe --tag `git rev-parse HEAD`) =~ "^[0-9]+.[0-9]+.[0-9]+$" ]] || \
214+
[[ $(git describe --tag `git rev-parse HEAD`) =~ "^[0-9]+.[0-9]+.[0-9]+-${BRANCH}.[0-9]+$" ]]
215+
then
216+
echo "Latest commit is already tagged"
217+
echo "IMAGE_VERSION=$(git describe --abbrev=0 --tags)" >> ./env-config
218+
exit 0
219+
fi
220+
211221
git fetch origin ${BRANCH} --tags
212222
git checkout ${BRANCH}
213223
git branch --set-upstream-to=origin/${BRANCH} ${BRANCH}
@@ -232,8 +242,7 @@ spec:
232242
--verbose \
233243
-VV
234244
235-
echo "IMAGE_VERSION=$(git describe --abbrev=0 --tags)" > ./env-config
236-
echo "IMAGE_NAME=$(basename -s .git `git config --get remote.origin.url` | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')" >> ./env-config
245+
echo "IMAGE_VERSION=$(git describe --abbrev=0 --tags)" >> ./env-config
237246
238247
cat ./env-config
239248
'''

0 commit comments

Comments
 (0)