Remove sudo in functest-kubernetes jjbs
[releng.git] / jjb / apex / apex-fetch-logs.sh
1 #!/usr/bin/env bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5
6 # log info to console
7 echo "Fetching logs from overcloud. This could take some time..."
8 echo "--------------------------------------------------------"
9 echo
10
11 if sudo opnfv-pyutil --fetch-logs; then
12   LOG_LOCATION=$(cat apex_util.log | grep 'Log retrieval complete' | grep -Eo '/tmp/.+$')
13   if [ -z "$LOG_LOCATION" ]; then
14       echo "WARNING: Unable to determine log location.  Logs will not be uploaded"
15       exit 0
16   else
17     sudo chmod 777 ${LOG_LOCATION}
18     UPLOAD_LOCATION="${GS_URL}/logs/${JOB_NAME}/${BUILD_NUMBER}/"
19     gsutil -m cp -r ${LOG_LOCATION} gs://${UPLOAD_LOCATION} > gsutil.latest_logs.log
20     echo -e "Logs available at: \n$(find ${LOG_LOCATION} -type f | sed -n 's#^/tmp/#http://'$UPLOAD_LOCATION'#p')"
21   fi
22 else
23   echo "WARNING: Log retrieval failed.  No logs will be uploaded"
24   exit 0
25 fi