Add better issue handling so we can track and capture exceptional circumstances

This commit is contained in:
Tianon Gravi 2014-09-24 11:52:03 -06:00
parent 64cede0941
commit 7a7c6adf20
1 changed files with 21 additions and 2 deletions

View File

@ -44,7 +44,7 @@ options:
EOUSAGE EOUSAGE
} }
opts="$(getopt -o 'h?' --long 'all,help,no-build,no-clone,library:,src:,logs:,namespaces:' -- "$@" || { usage >&2 && false; })" opts="$(getopt -o 'h?' --long 'all,help,no-clone,no-build,library:,src:,logs:,namespaces:' -- "$@" || { usage >&2 && false; })"
eval set -- "$opts" eval set -- "$opts"
doClone=1 doClone=1
@ -104,6 +104,8 @@ mkdir -p "$logDir"
latestLogDir="$logs/latest" # this gets shiny symlinks to the latest buildlog for each repo we've seen since the creation of the logs dir latestLogDir="$logs/latest" # this gets shiny symlinks to the latest buildlog for each repo we've seen since the creation of the logs dir
mkdir -p "$latestLogDir" mkdir -p "$latestLogDir"
didFail=
# gather all the `repo:tag` combos to build # gather all the `repo:tag` combos to build
for repoTag in "${repos[@]}"; do for repoTag in "${repos[@]}"; do
repo="${repoTag%%:*}" repo="${repoTag%%:*}"
@ -190,7 +192,8 @@ while [ "$#" -gt 0 ]; do
gitDir="${repoGitDir[$repoTag]}" gitDir="${repoGitDir[$repoTag]}"
shift shift
if [ -z "$gitRepo" ]; then if [ -z "$gitRepo" ]; then
echo >&2 'warning: skipping unknown repo:tag:' "$repoTag" echo >&2 'Unknown repo:tag:' "$repoTag"
didFail=1
continue continue
fi fi
@ -202,12 +205,25 @@ while [ "$#" -gt 0 ]; do
if ! ( cd "$gitRepo" && git rev-parse --verify "${gitRef}^{commit}" &> /dev/null ); then if ! ( cd "$gitRepo" && git rev-parse --verify "${gitRef}^{commit}" &> /dev/null ); then
echo "- skipped; invalid ref: $gitRef" echo "- skipped; invalid ref: $gitRef"
didFail=1
continue continue
fi fi
( set -x; cd "$gitRepo" && git clean -dfxq && git checkout -q "$gitRef" ) &>> "$thisLog" ( set -x; cd "$gitRepo" && git clean -dfxq && git checkout -q "$gitRef" ) &>> "$thisLog"
# TODO git tag # TODO git tag
if [ ! -d "$gitRepo/$gitDir" ]; then
echo "- skipped; invalid dir: $gitDir"
didFail=1
continue
fi
if [ ! -f "$gitRepo/$gitDir/Dockerfile" ]; then
echo "- skipped; missing $gitDir/Dockerfile"
didFail=1
continue
fi
IFS=$'\n' IFS=$'\n'
froms=( $(grep '^FROM[[:space:]]' "$gitRepo/$gitDir/Dockerfile" | awk -F '[[:space:]]+' '{ print $2 ~ /:/ ? $2 : $2":latest" }') ) froms=( $(grep '^FROM[[:space:]]' "$gitRepo/$gitDir/Dockerfile" | awk -F '[[:space:]]+' '{ print $2 ~ /:/ ? $2 : $2":latest" }') )
unset IFS unset IFS
@ -228,6 +244,7 @@ while [ "$#" -gt 0 ]; do
if ! ( set -x; docker build -t "$repoTag" "$gitRepo/$gitDir" ) &>> "$thisLog"; then if ! ( set -x; docker build -t "$repoTag" "$gitRepo/$gitDir" ) &>> "$thisLog"; then
echo "- failed; see $thisLog" echo "- failed; see $thisLog"
didFail=1
continue continue
fi fi
@ -236,3 +253,5 @@ while [ "$#" -gt 0 ]; do
done done
fi fi
done done
[ -z "$didFail" ]