Fix the "The controller is not up" problem caused by the fuel9.0 changing the online...
[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"
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' 'huawei-pod1')
27
28 if [[ ! " ${node_list[@]} " =~ " ${testbed} " ]]; then
29     echo "This is not a CI POD. Aborting pushing the logs to artifacts."
30     exit 0
31 fi
32
33 if [[ "$branch" == "master" ]]; then
34     project_artifact=logs/$project/$testbed/$res_build_date
35 else
36     project_artifact=logs/$project/$testbed/$branch/$res_build_date
37 fi
38
39 # create the folder to store the results
40 mkdir -p $dir_result
41
42 # copy folder to artifact
43 if [ -d "$dir_result" ]; then
44     if [ "$(ls -A $dir_result)" ]; then
45         set +e
46         gsutil&>/dev/null
47         if [ $? != 0 ]; then
48             echo "Not possible to push results to artifact: gsutil not installed";
49         else
50             gsutil ls gs://artifacts.opnfv.org/"$project"/ &>/dev/null
51             if [ $? != 0 ]; then
52                 echo "Not possible to push results to artifact: gsutil not installed.";
53             else
54                 echo "copy result files to artifact $project_artifact"
55                 gsutil -m cp -r "$dir_result" gs://artifacts.opnfv.org/"$project_artifact"/
56             fi
57         fi
58     else
59           echo "Result folder is empty"
60     fi
61 fi