From: Benjamin Drung Date: Thu, 24 Jul 2014 12:09:42 +0000 (+0200) Subject: add sbuild-post-build-get-reports script X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=0c16cc5a6a5e63375973b6587fedba1f8b3c873b;p=profitbricks%2Fjenkins-build-scripts.git add sbuild-post-build-get-reports script --- diff --git a/sbuild-post-build-get-reports b/sbuild-post-build-get-reports new file mode 100755 index 0000000..89e3d2d --- /dev/null +++ b/sbuild-post-build-get-reports @@ -0,0 +1,46 @@ +#!/bin/sh +set -e + +# FIXME: Fix sbuild to pass the chroot base path to this script! +dsc=$1 +chroots=$(find /var/lib/schroot/mount/*/build/ -maxdepth 2 -name $dsc | wc -l) +if test "$chroots" -eq 0; then + echo "$0: Failed to find chroot in /var/lib/schroot/mount." >&2 + exit 1 +elif test "$chroots" -gt 1; then + echo "$0: Found multiple chroots (but only one wanted):" >&2 + find /var/lib/schroot/mount/*/build/ -maxdepth 2 -name $dsc >&2 + exit 1 +fi +# FIXME: possible race condition +builddir=$(dirname $(find /var/lib/schroot/mount/*/build/ -maxdepth 2 -name $dsc)) + +# Determine git checkout directory (which is stored in the workspace) +# Note: Assume that $OLDPWD points to /deb-packages/$source +workspace=${OLDPWD}/../../workspace + +if echo "${BUILD_TRIGGERS}" | grep -q 'no-test'; then + echo "###" + echo "### Found build trigger 'no-test' so no reports.tgz will be created." + echo "###" +else + echo "###" + echo "### Find report files and copy them out of chroot." + echo "###" + + cd $builddir + if test "$(find * -maxdepth 0 -type d | wc -l)" -eq 1; then + # switch into extract Debian source directory + cd $(find * -maxdepth 0 -type d | head -n 1) + fi + + files=$(find . -name surefire-reports -o -name failsafe-reports -o -name unittest.log -o -name tests-0.log -o -name build.log -o -name test-run-all.xml | wc -l) + if test "$files" -eq 0; then + echo "Found no report files in $(pwd)." + else + echo "Found $files report files in $(pwd):" + find . -name surefire-reports -o -name failsafe-reports -o -name unittest.log -o -name tests-0.log -o -name build.log -o -name test-run-all.xml + + # Copy reports from the chroot into the workspace (for Jenkins) + find . -name surefire-reports -o -name failsafe-reports -o -name unittest.log -o -name tests-0.log -o -name build.log -o -name test-run-all.xml -exec install -D -m 644 {} $workspace/{} \; +fi