diff options
author | Mattia Rizzolo <mattia@debian.org> | 2017-05-17 10:47:44 +0200 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2017-05-18 02:06:40 +0200 |
commit | 13a8518d321a47199cdf39ae3d182392679c48a1 (patch) | |
tree | a41175d6b1cffd7cb465d665faf4ba4cb331446f | |
parent | c8baabe511fcda9fc198214b8b15bd4a282cf5c4 (diff) | |
download | jenkins.debian.net-13a8518d321a47199cdf39ae3d182392679c48a1.tar.xz |
chroot-run: support exporting build results out of the chroot
Thanks: Niels Thykier for the original patch!
Signed-off-by: Mattia Rizzolo <mattia@debian.org>
Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-x | bin/chroot-run.sh | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/bin/chroot-run.sh b/bin/chroot-run.sh index 813ef564..c26d3bb7 100755 --- a/bin/chroot-run.sh +++ b/bin/chroot-run.sh @@ -8,6 +8,10 @@ DEBUG=true . /srv/jenkins/bin/common-functions.sh common_init "$@" +EXPORTS_RESULTS=false +# Inside chroot (for the job process) +JENKINS_EXPORTS_DIR=/tmp/job-exports + # cp artifacts back into workspace if this is set if [ "$ARTIFACTS" != "true" ] ; then ARTIFACTS=false @@ -17,7 +21,7 @@ fi # $2 $3 ... = command to run inside a clean chroot running the distro in $1 if [ $# -lt 2 ]; then - echo "usage: $0 DISTRO [backports|minimal] CMD [ARG1 ARG2 ...]" + echo "usage: $0 DISTRO [backports|minimal] [--exports-results] CMD [ARG1 ARG2 ...]" exit 1 fi @@ -36,6 +40,12 @@ if [ "$1" = "minimal" ] ; then shift fi +if [ "$1" = "--exports-results" ]; then + EXPORTS_RESULTS=true + export JENKINS_EXPORTS_DIR + shift +fi + if [ ! -d "$CHROOT_BASE" ]; then echo "Directory $CHROOT_BASE does not exist, aborting." exit 1 @@ -73,6 +83,11 @@ bootstrap() { fi fi + if [ "$EXPORTS_RESULTS" = "true" ]; then + mkdir -p "$CHROOT_TARGET/$JENKINS_EXPORTS_DIR" + fi + + cat > $CHROOT_TARGET/tmp/chroot-prepare <<-EOF $SCRIPT_HEADER mount /proc -t proc /proc @@ -96,6 +111,15 @@ cleanup() { cp -v $CHROOT_TARGET/tmp/testrun/stats.csv $CURDIR fi + if [ "${EXPORTS_RESULTS}" = "true" ]; then + mkdir -p "$WORKSPACE/job-exports" + if [ ! -z "$(ls -1A "$CHROOT_TARGET/$JENKINS_EXPORTS_DIR")" ]; then + cp -drv "$CHROOT_TARGET/$JENKINS_EXPORTS_DIR"/* "$WORKSPACE/job-exports/" + else + echo "W: No exported results found in $JENKINS_EXPORTS_DIR" + fi + fi + # # special case: publish debian-edu-doc on the webserver # |