generated from remal-gradle-plugins/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
retry-connection-timeouts
executable file
·53 lines (37 loc) · 1.9 KB
/
retry-connection-timeouts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
DELAY_INTERVAL=60
HIGHLIGHT_COLOR='\033[1;33m'
TRACE_COLOR='\033[1;90m'
NO_COLOR='\033[0m'
RESULT=0
for ATTEMPT in $(seq 1 2); do
if [ "$ATTEMPT" -gt 1 ]; then
echo -e "\n${HIGHLIGHT_COLOR}Waiting $DELAY_INTERVAL seconds before attempt #$ATTEMPT...${NO_COLOR}\n"
sleep "$DELAY_INTERVAL"
fi
LOGFILE=$(mktemp)
#echo -e "${TRACE_COLOR}Executing $* command and storing its output to log file $LOGFILE${NO_COLOR}"
echo "::debug::Executing $* command and storing its output to log file $LOGFILE"
"$@" |& tee "$LOGFILE"
RESULT="${PIPESTATUS[0]}"
if [ "$RESULT" -eq 0 ]; then
exit 0
elif STR="connect timed out" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
elif STR="Connect Timeout Error" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
elif STR="Could not install Gradle distribution from" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
elif STR="Timeout has been exceeded" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
elif STR="Could not pack tree 'jvmArgumentProviders.jacocoAgent" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
elif STR="Could not get resource" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
elif STR="Received status code 429 from server" && grep --quiet --ignore-case "\b$STR\b" "$LOGFILE"; then
echo "::warning::'$STR' found in $* command log file $LOGFILE"
else
break
fi
done
exit "$RESULT"