jenkins.sh: stay in the jenkins workspace, not in /tmp

On jenkins, place all logs and manage docker volumes in the workspace instead
of a /tmp/* dir. Use $WORKSPACE/logs as docker volume base to begin with, thus
there needs to be no copy from /tmp to $WORKSPACE/logs.

On non-jenkins runs, place all in a /tmp/* dir still, but also skip copying of
the logs: just have a /tmp/logs symlink to the last tmpdir.

Change-Id: I8cf6014725ae8ba602be5f3ec31dfb8e49ff993e
This commit is contained in:
Neels Hofmeyr 2018-04-09 15:46:57 +02:00 committed by Neels Hofmeyr
parent aff7d1b4d8
commit 18392ee604
3 changed files with 16 additions and 13 deletions

View File

@ -11,8 +11,7 @@ network_remove() {
}
collect_logs() {
cp -a "$VOL_BASE_DIR"/* "$WORKSPACE"/logs/
cat "$WORKSPACE"/logs/*/junit-*.log || true
cat "$VOL_BASE_DIR"/*/junit-*.log || true
}
set -x
@ -22,9 +21,18 @@ if [ "x$REPO_USER" = "x" ]; then
REPO_USER=$USER
fi
# non-jenkins execution: put logs in /tmp
if [ "x$WORKSPACE" = "x" ]; then
WORKSPACE=/tmp
# non-jenkins execution: put logs in /tmp
VOL_BASE_DIR="$(mktemp -d)"
# point /tmp/logs to the last ttcn3 run
rm /tmp/logs || true
ln -s "$VOL_BASE_DIR" /tmp/logs || true
else
# jenkins execution: put logs in workspace
VOL_BASE_DIR="$WORKSPACE/logs"
rm -rf "$VOL_BASE_DIR"
mkdir -p "$VOL_BASE_DIR"
fi
# non-jenkins execution: put logs in /tmp
@ -35,8 +43,3 @@ fi
SUITE_NAME=`basename $PWD`
NET_NAME=$SUITE_NAME
VOL_BASE_DIR=`mktemp -d`
rm -rf $WORKSPACE/logs || /bin/true
mkdir -p $WORKSPACE/logs

View File

@ -23,7 +23,7 @@ docker run --rm \
--network $NET_NAME --ip 172.18.6.3 \
-v $VOL_BASE_DIR/sua-tester:/data \
--name ${BUILD_TAG}-sua-test \
$REPO_USER/sua-test > $WORKSPACE/logs/junit-xml-sua.log
$REPO_USER/sua-test > $VOL_BASE_DIR/junit-xml-sua.log
docker container stop -t 1 ${BUILD_TAG}-stp

View File

@ -43,9 +43,9 @@ docker run --rm \
-v bts-vol:/bts \
--name ${BUILD_TAG}-sysinfo-helper -d \
busybox /bin/sh -c 'sleep 1000 & wait'
docker cp ${BUILD_TAG}-sysinfo-helper:/ttcn3-nitb-sysinfo $WORKSPACE/logs
docker cp ${BUILD_TAG}-sysinfo-helper:/nitb $WORKSPACE/logs
docker cp ${BUILD_TAG}-sysinfo-helper:/bts $WORKSPACE/logs
docker cp ${BUILD_TAG}-sysinfo-helper:/ttcn3-nitb-sysinfo $VOL_BASE_DIR
docker cp ${BUILD_TAG}-sysinfo-helper:/nitb $VOL_BASE_DIR
docker cp ${BUILD_TAG}-sysinfo-helper:/bts $VOL_BASE_DIR
docker container stop -t 0 ${BUILD_TAG}-sysinfo-helper
network_remove