Skip to content

Instantly share code, notes, and snippets.

@m1kc
Created October 3, 2013 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m1kc/6808732 to your computer and use it in GitHub Desktop.
Save m1kc/6808732 to your computer and use it in GitHub Desktop.
travis_retry() {
local result=0
local count=3
while [ $count -gt 0 ]; do
"$@"
result=$?
[[ "$result" == "0" ]] && break
count=$(($count - 1))
echo "Command ($@) failed. Retrying: $((3 - $count))" >&2
sleep 1
done
[ $count -eq 0 ] && {
echo "Retry failed: $@" >&2
}
return $result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment