From 26a6ed5873aa41481cbe69e95a0e2220539d64ef Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 9 Feb 2016 01:40:44 +0530 Subject: [PATCH] Add CI script to retry builds --- etc/ci/retry.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 etc/ci/retry.sh diff --git a/etc/ci/retry.sh b/etc/ci/retry.sh new file mode 100755 index 00000000000..4c036085108 --- /dev/null +++ b/etc/ci/retry.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Retries a given command until it passes +# Run as `retry.sh N command args...` +# where `N` is the maximum number of tries, and `command args...` is the +# command to run, with arguments + +n=$1 +shift; # this removes the first argument from $@ +for i in `seq $n`; do + echo "====== RUN NUMBER: $i ======"; + if $@ # run command, check if exit code is zero + then + exit 0 # command passed, all is well + fi +done +exit 1