From 9b9b3ae37a3d9502906bd84cc3a0176bfc4276c8 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 29 Jun 2018 09:43:45 +0100 Subject: [PATCH] Retry npm step 5 times with 5 second pause (#18918) --- dev/bots/travis_install.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dev/bots/travis_install.sh b/dev/bots/travis_install.sh index bee490c0fe..bbe52f8514 100755 --- a/dev/bots/travis_install.sh +++ b/dev/bots/travis_install.sh @@ -1,8 +1,25 @@ #!/bin/bash set -ex +function retry { + local total_tries=$1 + local remaining_tries=$total_tries + shift + while [ $remaining_tries -gt 0 ]; do + "$@" && break + remaining_tries=$(($remaining_tries - 1)) + sleep 5 + done + + [ $remaining_tries -eq 0 ] && { + echo "Command still failed after $total_tries tries: $@" + return 1 + } + return 0 +} + if [ -n "$TRAVIS" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then gem install coveralls-lcov gem install bundler - npm install -g firebase-tools@">=3.6.1 <3.7.0" + retry 5 npm install -g firebase-tools@">=3.6.1 <3.7.0" fi