From b41757448dd267b06bc4484acf7625a42cd34337 Mon Sep 17 00:00:00 2001 From: Alex Iribarren Date: Fri, 10 Dec 2021 11:04:28 +0100 Subject: [PATCH] Retry job submissions up to 3 times --- gitlab-ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gitlab-ci.yml b/gitlab-ci.yml index 9a48c0f..c27a789 100644 --- a/gitlab-ci.yml +++ b/gitlab-ci.yml @@ -39,7 +39,26 @@ deploy: extends: .nomad stage: deploy script: - - for j in *.nomad; do echo -e "\n${j}:"; nomad job run <(envsubst < $j); done + - set +e + - | + for j in *.nomad; do + COUNT=0 + echo -e "\n${j}:" + while [[ $COUNT -lt 3 ]]; then + nomad job run <(envsubst < $j) + RET=$? + if [[ $RET -eq 0 ]]; then + break + fi + COUNT=$(($COUNT+1)) + sleep 30s + done + if [[ $RET -ne 0 ]]; then + echo "Failed to deploy job ${j}" + exit 1 + fi + done + - set -e stop_testing: extends: .nomad -- GitLab