[PATCH] docker-playground[master]: jenkins.sh: stay in the jenkins workspace, not in /tmp

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Apr 18 15:38:29 UTC 2018


Review at  https://gerrit.osmocom.org/7868

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
---
M jenkins-common.sh
M sua-test/jenkins.sh
M ttcn3-nitb-sysinfo/jenkins.sh
3 files changed, 16 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/68/7868/1

diff --git a/jenkins-common.sh b/jenkins-common.sh
index 281807a..515479f 100644
--- a/jenkins-common.sh
+++ b/jenkins-common.sh
@@ -11,8 +11,7 @@
 }
 
 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 @@
 	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 @@
 SUITE_NAME=`basename $PWD`
 
 NET_NAME=$SUITE_NAME
-
-VOL_BASE_DIR=`mktemp -d`
-
-rm -rf $WORKSPACE/logs || /bin/true
-mkdir -p $WORKSPACE/logs
diff --git a/sua-test/jenkins.sh b/sua-test/jenkins.sh
index 7c1939e..0f87b4e 100755
--- a/sua-test/jenkins.sh
+++ b/sua-test/jenkins.sh
@@ -23,7 +23,7 @@
 		--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
 
diff --git a/ttcn3-nitb-sysinfo/jenkins.sh b/ttcn3-nitb-sysinfo/jenkins.sh
index ac00642..530b4ee 100755
--- a/ttcn3-nitb-sysinfo/jenkins.sh
+++ b/ttcn3-nitb-sysinfo/jenkins.sh
@@ -43,9 +43,9 @@
 		-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

-- 
To view, visit https://gerrit.osmocom.org/7868
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cf6014725ae8ba602be5f3ec31dfb8e49ff993e
Gerrit-PatchSet: 1
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list