File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 2323 - name : Grant execute permission for gradlew
2424 run : chmod +x gradlew
2525 - name : Build with Gradle
26- run : . /gradlew build
26+ run : scripts/retry.sh 3 ". /gradlew clean build"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Usage: retry.sh <max_tries> <command to run>
3+
4+ readonly max_tries=$1
5+ readonly command=" ${@: 2} "
6+ attempts=0
7+ return_code=1
8+ while [[ $attempts -lt $max_tries ]]; do
9+ (( attempts++ ))
10+ if [[ attempts -gt 1 ]]; then sleep 10; fi
11+ echo " RETRY: Attempt $attempts of $max_tries ."
12+ $command && break
13+ done
14+
15+ return_code=$?
16+
17+ if [[ $return_code == 0 ]]; then
18+ echo " RETRY: Attempt $attempts succeeded."
19+ else
20+ echo " RETRY: All $attempts attempts failed."
21+ fi
22+
23+ exit $return_code
You can’t perform that action at this time.
0 commit comments