diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2687d7fb6a4d4fc06f9a1d96ab094f211f1de085..92d458e7fffb3b329cc02a64dee59b0c93875885 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -868,19 +868,7 @@ kube-prometheus-stack-alerts: - *debug_information script: # Retry taiko tests multiple times until they succeed - - | - set -o pipefail - i=0 - until unbuffer python3 -m openappstack $HOSTNAME test --apps $RESOURCE | ts -i | ts - do - if [[ $i -ge 20 ]] - then - exit 1 - fi - (( i++ )) - sleep 1 - echo -e "${i}. retry:\n" - done + - bash ./.gitlab/ci_scripts/retry_cmd_until_success.sh 20 unbuffer python3 -m openappstack $HOSTNAME test --apps $RESOURCE | ts -i | ts artifacts: paths: - test/taiko/Screenshot* diff --git a/.gitlab/ci_scripts/retry_cmd_until_success.sh b/.gitlab/ci_scripts/retry_cmd_until_success.sh new file mode 100755 index 0000000000000000000000000000000000000000..33c8aa78d52a628c5caec9e4037d97f0d4577b35 --- /dev/null +++ b/.gitlab/ci_scripts/retry_cmd_until_success.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Executes given cms multiple times until it is successful +# +# Usage: +# +# ./retry_cmd_until_success.sh [retries] [cmd] +# +# Example: +# +# ./retry_cmd_until_success.sh 10 ping ix.de + +retries=$1 +shift +cmd=$* + +if [[ ! $retries =~ ^-?[0-9]+$ ]] +then + echo "Please specify retries count." + exit 1 +fi + +if [[ -z "$cmd" ]] +then + echo "Please specify a cmd." + exit 1 +fi +echo "Retrying \"$cmd\" ${retries} times." + +i=0 +until eval $cmd +do + echo -e "return code: $?\n" + if [[ $i -ge 2 ]] + then + exit 1 + fi + (( i++ )) + sleep 1 + echo "${i}. retry:" +done