jenkins.sh: have one common function to collect logs

To remove code dup and prepare a change to where logs are written, add
collect_logs() to jenkins_common.sh and call that from each jenkins.sh after
the tests are done.

The 'rm -rf' is already done before a test starts. No need to do that again
after each test.

Change-Id: I5d8472ec36b07c828685b1bd7718e31392d168a3
This commit is contained in:
Neels Hofmeyr 2018-04-09 15:28:25 +02:00 committed by Neels Hofmeyr
parent 9f5131ab9d
commit 2f61bf81e9
12 changed files with 15 additions and 52 deletions

View File

@ -10,7 +10,10 @@ network_remove() {
docker network remove $NET_NAME
}
collect_logs() {
cp -a "$VOL_BASE_DIR"/* "$WORKSPACE"/logs/
cat "$WORKSPACE"/logs/*/junit-*.log || true
}
set -x

View File

@ -28,6 +28,4 @@ docker run --rm \
docker container stop -t 1 ${BUILD_TAG}-stp
network_remove
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/m3ua-tester/junit-*.log || true
collect_logs

View File

@ -10,9 +10,6 @@ cp osmo-stp.cfg $VOL_BASE_DIR/stp/
network_create 172.18.6.0/24
rm -rf $WORKSPACE/logs || /bin/true
mkdir -p $WORKSPACE/logs
# start container with STP in background
docker run --rm \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
@ -31,6 +28,4 @@ docker run --rm \
docker container stop -t 1 ${BUILD_TAG}-stp
network_remove
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/sua-tester/junit-*.log || true
collect_logs

View File

@ -51,8 +51,4 @@ docker container kill ${BUILD_TAG}-bsc
docker container kill ${BUILD_TAG}-stp
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/bsc-tester/junit-*.log || true
collect_logs

View File

@ -66,9 +66,5 @@ docker container kill ${BUILD_TAG}-bts
docker container kill ${BUILD_TAG}-bsc
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
rm -rf $VOL_BASE_DIR/unix
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/bts-tester/junit-*.log || true
collect_logs

View File

@ -34,8 +34,4 @@ docker run --rm \
docker container stop ${BUILD_TAG}-ggsn
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/ggsn-tester/junit-*.log || true
collect_logs

View File

@ -30,8 +30,4 @@ echo Stopping containers
docker container kill ${BUILD_TAG}-hlr
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/hlr-tester/junit-*.log || true
collect_logs

View File

@ -30,8 +30,4 @@ docker run --rm \
docker container stop ${BUILD_TAG}-mgw
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/mgw-tester/junit-*.log || true
collect_logs

View File

@ -47,9 +47,5 @@ docker container kill ${BUILD_TAG}-msc
docker container kill ${BUILD_TAG}-stp
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
rm -rf $VOL_BASE_DIR/unix
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/msc-tester/junit-*.log || true
collect_logs

View File

@ -43,11 +43,10 @@ docker run --rm \
-v bts-vol:/bts \
--name ${BUILD_TAG}-sysinfo-helper -d \
busybox /bin/sh -c 'sleep 1000 & wait'
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
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 container stop -t 0 ${BUILD_TAG}-sysinfo-helper
network_remove
collect_logs

View File

@ -32,8 +32,4 @@ echo Stopping containers
docker container kill ${BUILD_TAG}-sgsn
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/sgsn-tester/junit-*.log || true
collect_logs

View File

@ -36,9 +36,5 @@ echo Stopping containers
docker container kill ${BUILD_TAG}-sip-connector
network_remove
rm -rf $WORKSPACE/logs
mkdir -p $WORKSPACE/logs
rm -rf $VOL_BASE_DIR/unix
cp -a $VOL_BASE_DIR/* $WORKSPACE/logs/
cat $WORKSPACE/logs/sip-tester/junit-*.log || true
collect_logs