git.iko.soy/typeable/servant
on master help sign in
Add travis_retry bash function
commite022ad0b23694ef40d849a220f690c820595fb76 authorJulian K. Arni <jkarni@gmail.com> dateFri 12 Jun 2015, 14:37 (11 years ago) parent29de4f5
1 file changed+23
scripts/lib/common.sh+23
scripts/lib/common.sh+23
@@ -29,3 +29,26 @@ versions_equal () {
2929 echo "versions of packages are not all the same!" && exit 1
3030 fi
3131}
32+
33+travis_retry() {
34+ # From
35+ # https://github.com/travis-ci/travis-build/blob/18bd04e965b9bfaa49cd6bdcd8dcb1513b8d2fcd/lib/travis/build/templates/header.sh
36+ local result=0
37+ local count=1
38+ while [ $count -le 3 ]; do
39+ [ $result -ne 0 ] && {
40+ echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
41+ }
42+ "$@"
43+ result=$?
44+ [ $result -eq 0 ] && break
45+ count=$(($count + 1))
46+ sleep 1
47+ done
48+
49+ [ $count -gt 3 ] && {
50+ echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
51+ }
52+
53+ return $result
54+}