From 951fcf2afaeb5c5e6c66ea0cccf61f05f6d5d36e Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Thu, 3 Oct 2024 15:18:42 +0400 Subject: [PATCH] UBERF-8328: Fail CI on docker push failure (#6794) Signed-off-by: Alexey Zinoviev --- common/scripts/docker_tag.sh | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/common/scripts/docker_tag.sh b/common/scripts/docker_tag.sh index b6dd465b221..ffbb926f54c 100755 --- a/common/scripts/docker_tag.sh +++ b/common/scripts/docker_tag.sh @@ -9,12 +9,19 @@ then c=( ${a[2]//[^0-9]*/ } ) ((c++)) version="${a[0]}.${a[1]}.${c}-staging" - echo "Tagging stating $1 with version ${version}" + echo "Tagging staging $1 with version ${version}" docker tag "$1:$rev_version" "$1:$version" for n in {1..5}; do docker push "$1:$version" && break - echo 'Docker failed to push, wait 5 seconds' - sleep 5 + + if (( $n < 5 )) + then + echo 'Docker failed to push, wait 5 second' + sleep 5 + else + echo '5 push attempts failed, exiting with failure' + exit 1 + fi done else echo "Tagging release $1 with version ${version}" @@ -22,12 +29,26 @@ else docker tag "$1:$rev_version" "$1:latest" for n in {1..5}; do docker push "$1:$version" && break - echo 'Docker failed to push, wait 5 seconds' - sleep 5 + + if (( $n < 5 )) + then + echo 'Docker failed to push, wait 5 second' + sleep 5 + else + echo '5 push attempts failed, exiting with failure' + exit 1 + fi done for n in {1..5}; do docker push "$1:latest" && break - echo 'Docker failed to push, wait 5 seconds' - sleep 5 + + if (( $n < 5 )) + then + echo 'Docker failed to push, wait 5 second' + sleep 5 + else + echo '5 push attempts failed, exiting with failure' + exit 1 + fi done fi