Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
exec > >(logger -i -t autopkg-build) 2>&1
BUILD_RECIPE_DIR="/dir/with/autopkg/recipenames"
EMAIL_ERRORS_TO='blah@acme.com'
my_name=$(basename $0)
# Allows us to get exit code of autopkg and not tee
set -o pipefail
echo "$(date) BEGIN AUTOPKG BUILD RUN"
for recipe in $(cd ${BUILD_RECIPE_DIR}; ls ); do
OUTPUT_FILE=$(mktemp /tmp/${my_name}.XXXXXXXXX)
echo "$(date) Autopkg running ${recipe} ... "
/usr/local/bin/autopkg run ${recipe} | tee ${OUTPUT_FILE}
if [ $? -ne 0 ]; then
mail -s "Failed to build ${recipe}" ${EMAIL_ERRORS_TO} < ${OUTPUT_FILE}
fi
echo "$(date) ... end run of $recipe"
rm -f ${OUTPUT_FILE}
done
echo "$(date) END AUTOPKG BUILD RUN"
Owner

fuzzylogiq commented Nov 2, 2015

Relies on having a dir with files with the same name as recipes you want to run (we use symlinks to recipes/overrides in a separate dir so we can add/remove them easily from the build process)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment