Merge "Concurrent true for opnfv-yamllint-verify-master"
[releng.git] / utils / push-test-logs.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 set -e
11 set -o pipefail
12
13 export PATH=$PATH:/usr/local/bin/
14
15 git_sha1="$(git rev-parse HEAD)"
16 res_build_date=${1:-$(date -u +"%Y-%m-%d_%H-%M-%S")}
17 project=$PROJECT
18 branch=${GIT_BRANCH##*/}
19 testbed=$NODE_NAME
20 dir_result="${HOME}/opnfv/$project/results/${branch}"
21 # src: https://wiki.opnfv.org/display/INF/Hardware+Infrastructure
22 # + intel-pod3 (vsperf)
23 node_list=(\
24 'lf-pod1' 'lf-pod2' 'intel-pod2' 'intel-pod3' \
25 'intel-pod5' 'intel-pod6' 'intel-pod7' 'intel-pod8' \
26 'ericsson-pod2' 'ericsson-pod3' 'ericsson-pod4' \
27 'ericsson-virtual1' 'ericsson-virtual2'  'ericsson-virtual3' \
28 'ericsson-virtual4' 'ericsson-virtual5' \
29 'arm-pod1' 'arm-pod3' \
30 'huawei-pod1' 'huawei-pod2' 'huawei-virtual1' 'huawei-virtual2' 'huawei-virtual3' 'huawei-virtual4')
31
32
33 if [[ ! " ${node_list[@]} " =~ " ${testbed} " ]]; then
34     echo "This is not a CI POD. Aborting pushing the logs to artifacts."
35     exit 0
36 fi
37
38 if [[ "$branch" == "master" ]]; then
39     project_artifact=logs/$project/$testbed/$res_build_date
40 else
41     project_artifact=logs/$project/$testbed/$branch/$res_build_date
42 fi
43
44 # create the folder to store the results
45 mkdir -p $dir_result
46
47 # copy folder to artifact
48 if [ -d "$dir_result" ]; then
49     if [ "$(ls -A $dir_result)" ]; then
50         set +e
51         gsutil&>/dev/null
52         if [ $? != 0 ]; then
53             echo "Not possible to push results to artifact: gsutil not installed";
54         else
55             gsutil ls gs://artifacts.opnfv.org/"$project"/ &>/dev/null
56             if [ $? != 0 ]; then
57                 echo "Not possible to push results to artifact: some error happened when using gsutil";
58             else
59                 echo "Uploading logs to artifact $project_artifact"
60                 gsutil -m cp -r "$dir_result"/* gs://artifacts.opnfv.org/"$project_artifact"/ >/dev/null 2>&1
61                 echo "Logs can be found in http://artifacts.opnfv.org/logs_${project}_${testbed}.html"
62                 cd $dir_result
63                 files=($(find . -name \* -print|sed 's/^\.//'|sed '/^\s*$/d'))
64                 for f in ${files[@]}; do
65                     echo "http://artifacts.opnfv.org/${project_artifact}${f}"
66                 done
67             fi
68         fi
69     else
70           echo "Result folder is empty"
71     fi
72 fi