Skip to content

Instantly share code, notes, and snippets.

@hmanzur
Created April 8, 2021 17:17
Show Gist options
  • Save hmanzur/4e5aa7edb782715779d4859a61b96de4 to your computer and use it in GitHub Desktop.
Save hmanzur/4e5aa7edb782715779d4859a61b96de4 to your computer and use it in GitHub Desktop.
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
# File that contains failures.
failure_file=failure.log
touch ${failure_file}
for d in portal/*/; do
config="${d}cloudbuild.yaml"
if [[ ! -f "${config}" ]]; then
continue
fi
echo "Building $d ... "
(
logfile="${d::-1}.log" # Logfile for "foo/" builder is "foo.log".
gcloud builds submit $d --config=${config} > ${logfile} 2>&1
if [[ $? -ne 0 ]]; then
echo "$d failed" | tee -a ${failure_file}
cat ${logfile}
fi
) &
done
wait
# Check if there is any failure.
if [[ -s ${failure_file} ]]; then
echo
echo "Some builds failed:"
cat ${failure_file}
echo "Exiting."
exit 1
fi
echo "All builds succeeded."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment