From 1105752564aefa45bf5f609e2a493304da6fbd3f Mon Sep 17 00:00:00 2001 From: MohitMali Date: Wed, 11 Jan 2023 12:39:52 +0530 Subject: [PATCH] Added retry in bash script --- contrib/instrumentation.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/contrib/instrumentation.sh b/contrib/instrumentation.sh index bb40a6f22..b77fea836 100644 --- a/contrib/instrumentation.sh +++ b/contrib/instrumentation.sh @@ -2,9 +2,21 @@ adb logcat -c adb logcat *:E -v color & -if ./gradlew jacocoInstrumentationTestReport; then - echo "jacocoInstrumentationTestReport succeeded" >&2 -else - adb exec-out screencap -p >screencap.png - exit 1 -fi +retry=0 +while [ $retry -le 3 ] +do + if ./gradlew jacocoInstrumentationTestReport; then + echo "jacocoInstrumentationTestReport succeeded" >&2 + break + else + adb kill-server + adb start-server + adb logcat -c + ./gradlew clean + retry=$(( $retry + 1 )) + if [ $retry == 3 ]; then + adb exec-out screencap -p >screencap.png + exit 1 + fi + fi +done