Skip to content

Commit

Permalink
Prevent some random build failures when connectivity fails, by callin…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Apr 30, 2014
1 parent 4c6b372 commit 5f168c7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/angularjs/scripts/install-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Prevent random build failures by retrying 3 times
# Source: https://github.com/travis-ci/travis-build/blob/fc4ae8a2ffa1f2b3a2f62533bbc4f8a9be19a8ae/lib/travis/build/script/templates/header.sh#L104
travis_retry() {
local result=0
local count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\n${RED}The command \"$@\" failed. Retrying, $count of 3.${RESET}\n" >&2
}
"$@"
result=$?
[ $result -eq 0 ] && break
count=$(($count + 1))
sleep 1
done

[ $count -eq 3 ] && {
echo "\n${RED}The command \"$@\" failed 3 times.${RESET}\n" >&2
}

return $result
}

DIR=`dirname $0`
cd $DIR
travis_retry sudo apt-get -qq install python-software-properties
Expand Down

0 comments on commit 5f168c7

Please sign in to comment.