2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/.ci/common.sh

34 lines
666 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
set -o pipefail
2016-02-19 08:00:59 +00:00
ANSI_RED="\033[31;1m"
# shellcheck disable=SC2034
2016-02-19 08:00:59 +00:00
ANSI_GREEN="\033[32;1m"
ANSI_RESET="\033[0m"
travis_retry() {
local result=0
local count=1
set +e
while [ ${count} -le 3 ]; do
[ ${result} -ne 0 ] && {
echo -e "\n${ANSI_RED}The command \"$*\" failed. Retrying, ${count} of 3.${ANSI_RESET}\n" >&2
}
"$@"
result=$?
[ ${result} -eq 0 ] && break
count=$((count + 1))
sleep 1
done
2016-02-19 08:00:59 +00:00
[ ${count} -gt 3 ] && {
echo -e "\n${ANSI_RED}The command \"$*\" failed 3 times.${ANSI_RESET}\n" >&2
}
2016-02-19 08:00:59 +00:00
set -e
return ${result}
2016-02-19 08:00:59 +00:00
}