Change jenkins user:group name according to Node Name. 45/31645/4
authorzshi <zshi@redhat.com>
Fri, 24 Mar 2017 02:06:27 +0000 (10:06 +0800)
committerAric Gardner <agardner@linuxfoundation.org>
Tue, 28 Mar 2017 12:43:54 +0000 (12:43 +0000)
JIRA: DOVETAIL-377

Change-Id: I55eebdd55c2cf91d74d166b0b31a0601efe0a751
Signed-off-by: zshi <zshi@redhat.com>
jjb/dovetail/dovetail-run.sh

index f9a3df6..4b00ec8 100755 (executable)
@@ -85,9 +85,11 @@ echo "Container exec command: ${run_cmd}"
 docker exec $container_id ${run_cmd}
 
 sudo cp -r ${DOVETAIL_REPO_DIR}/results ./
-#To make sure the file owner is jenkins, for the copied results files in the above line
+#To make sure the file owner is the current user, for the copied results files in the above line
 #if not, there will be error when next time to wipe workspace
-sudo chown -R jenkins:jenkins ${WORKSPACE}/results
+CURRENT_USER=${SUDO_USER:-$USER}
+PRIMARY_GROUP=$(id -gn $CURRENT_USER)
+sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ${WORKSPACE}/results
 
 echo "Dovetail: done!"