jenkins: retry build_devel (#30628)
* will it work
* retry build devel
* correct p[ath
* try a failure
* Revert "try a failure"
This reverts commit ba4e6a0a20
.
pull/30632/head
parent
f16df8e4b7
commit
36bebb1aa0
3 changed files with 29 additions and 1 deletions
@ -0,0 +1,27 @@ |
||||
#!/bin/bash |
||||
|
||||
function fail { |
||||
echo $1 >&2 |
||||
exit 1 |
||||
} |
||||
|
||||
function retry { |
||||
local n=1 |
||||
local max=3 # 3 retries before failure |
||||
local delay=5 # delay between retries, 5 seconds |
||||
while true; do |
||||
echo "Running command '$@' with retry, attempt $n/$max" |
||||
"$@" && break || { |
||||
if [[ $n -lt $max ]]; then |
||||
((n++)) |
||||
sleep $delay; |
||||
else |
||||
fail "The command has failed after $n attempts." |
||||
fi |
||||
} |
||||
done |
||||
} |
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then |
||||
retry "$@" |
||||
fi |
Loading…
Reference in new issue