From: valentin.radulescu Date: Tue, 26 Nov 2019 15:17:44 +0000 (-0800) Subject: Change owner of results folder and its files X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F55%2F2055%2F4;p=ci-management.git Change owner of results folder and its files JIRA: VAL-88 Remove the trap from the script. Change the owner after the scripts exists. Signed-off-by: valentin.radulescu Change-Id: I9284c041c436f7ca173b61e3d5d87fdc85581ebb --- diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh index 5870ed9..c701b0f 100755 --- a/jjb/shell/run_bluval.sh +++ b/jjb/shell/run_bluval.sh @@ -12,18 +12,21 @@ set -o errexit set -o pipefail cwd=$(pwd) +current_user=$(whoami) is_optional="false" -finish() { - # Fix ownership of output files - user_id=$(stat -c '%u:%g' $cwd) - sudo chown -R ${user_id} $results_dir -} - info () { logger -s -t "run_blu_val.info" "$*" } +change_res_owner() { +# change owner of results created by root in container + if [ -d "$results_dir" ] + then + sudo chown -R "$current_user" "$results_dir" + fi +} + usage() { echo "usage: $0 -n " >&2 echo "[-r results dir">&2 @@ -118,8 +121,6 @@ then fi fi -trap finish EXIT - if [ ! -d "$cwd/validation" ] then git clone http://gerrit.akraino.org/r/validation @@ -142,5 +143,17 @@ if [ "$is_optional" == "true" ] || [ "$OPTIONAL" == "yes" ] then options+=" -o" fi + +set +e +# even if the script fails we need to change the owner of results # shellcheck disable=SC2086 python3 validation/bluval/blucon.py $options "$blueprint_name" + +if [ $? -ne 0 ]; then + change_res_owner + error "Bluval validation failed!" +fi + +set -e + +change_res_owner