Add "retries" logic for build and push (since sometimes it just needs a little kick and everything works fine)
This commit is contained in:
parent
5aabe0b5be
commit
fbe0b0e47f
33
bashbrew.sh
33
bashbrew.sh
|
|
@ -11,6 +11,7 @@ src="$dir/src"
|
||||||
logs="$dir/logs"
|
logs="$dir/logs"
|
||||||
namespaces='_'
|
namespaces='_'
|
||||||
docker='docker'
|
docker='docker'
|
||||||
|
retries='4'
|
||||||
|
|
||||||
library="$(readlink -f "$library")"
|
library="$(readlink -f "$library")"
|
||||||
src="$(readlink -f "$src")"
|
src="$(readlink -f "$src")"
|
||||||
|
|
@ -33,6 +34,10 @@ usage() {
|
||||||
--all Build all repositories specified in library
|
--all Build all repositories specified in library
|
||||||
--docker="$docker"
|
--docker="$docker"
|
||||||
Use a custom Docker binary
|
Use a custom Docker binary
|
||||||
|
--retries="$retries"
|
||||||
|
How many times to try again if the build/push fails before
|
||||||
|
considering it a lost cause (always attempts a minimum of
|
||||||
|
one time, but maximum of one plus this number)
|
||||||
--help, -h, -? Print this help message
|
--help, -h, -? Print this help message
|
||||||
--library="$library"
|
--library="$library"
|
||||||
Where to find repository manifest files
|
Where to find repository manifest files
|
||||||
|
|
@ -67,7 +72,7 @@ usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# arg handling
|
# arg handling
|
||||||
opts="$(getopt -o 'h?' --long 'all,docker:,help,library:,logs:,namespaces:,no-build,no-clone,no-push,src:,uniq' -- "$@" || { usage >&2 && false; })"
|
opts="$(getopt -o 'h?' --long 'all,docker:,help,library:,logs:,namespaces:,no-build,no-clone,no-push,retries:,src:,uniq' -- "$@" || { usage >&2 && false; })"
|
||||||
eval set -- "$opts"
|
eval set -- "$opts"
|
||||||
|
|
||||||
doClone=1
|
doClone=1
|
||||||
|
|
@ -88,6 +93,7 @@ while true; do
|
||||||
--no-build) doBuild= ;;
|
--no-build) doBuild= ;;
|
||||||
--no-clone) doClone= ;;
|
--no-clone) doClone= ;;
|
||||||
--no-push) doPush= ;;
|
--no-push) doPush= ;;
|
||||||
|
--retries) retries="$1" && (( retries++ )) && shift ;;
|
||||||
--src) src="$1" && shift ;;
|
--src) src="$1" && shift ;;
|
||||||
--uniq) onlyUniq=1 ;;
|
--uniq) onlyUniq=1 ;;
|
||||||
--) break ;;
|
--) break ;;
|
||||||
|
|
@ -353,11 +359,15 @@ while [ "$#" -gt 0 ]; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ( set -x && "$docker" build -t "$repoTag" "$gitRepo/$gitDir" ) &>> "$thisLog"; then
|
tries="$retries"
|
||||||
echo "- failed 'docker build'; see $thisLog"
|
while ! ( set -x && "$docker" build -t "$repoTag" "$gitRepo/$gitDir" ) &>> "$thisLog"; do
|
||||||
didFail=1
|
(( tries-- )) || true
|
||||||
continue
|
if [ $tries -le 0 ]; then
|
||||||
fi
|
echo >&2 "- failed 'docker build'; see $thisLog"
|
||||||
|
didFail=1
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
for namespace in $namespaces; do
|
for namespace in $namespaces; do
|
||||||
if [ "$namespace" = '_' ]; then
|
if [ "$namespace" = '_' ]; then
|
||||||
|
|
@ -389,9 +399,14 @@ while [ "$#" -gt 0 ]; do
|
||||||
fi
|
fi
|
||||||
if [ "$doPush" ]; then
|
if [ "$doPush" ]; then
|
||||||
echo "Pushing $namespace/$repoTag..."
|
echo "Pushing $namespace/$repoTag..."
|
||||||
if ! "$docker" push "$namespace/$repoTag" &>> "$thisLog" < /dev/null; then
|
tries="$retries"
|
||||||
echo >&2 "- $namespace/$repoTag failed to push; see $thisLog"
|
while ! ( set -x && "$docker" push "$namespace/$repoTag" < /dev/null ) &>> "$thisLog"; do
|
||||||
fi
|
(( tries-- )) || true
|
||||||
|
if [ $tries -le 0 ]; then
|
||||||
|
echo >&2 "- $namespace/$repoTag failed to push; see $thisLog"
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
else
|
else
|
||||||
echo "$docker push" "$namespace/$repoTag"
|
echo "$docker push" "$namespace/$repoTag"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue