a9c5dbe1b50b051434b90118bb5cf1280b3bdaf7
[releng.git] / jjb / functest / res-build.sh
1 #!/bin/bash
2 set -e
3 set -o pipefail
4
5 export PATH=$PATH:/usr/local/bin/
6
7 git_sha1="$(git rev-parse HEAD)"
8 res_build_date=$(date -u +"%Y-%m-%d_%H-%M-%S")
9
10 # Result directory in the docker file
11 # to be used only with CI
12 dir_result="/home/opnfv/functest/results"
13
14 # Clean the results directory
15 # remove json file for rally, export only html
16 # json should have been pushed into the DB
17 rm -f $dir_result/rally/*.json
18
19 # Several information are required: date and testbed
20 # date is generated by functest so on the artifact, the results shall be under functest/<testbed id>/date/
21 testbed=$NODE_NAME
22
23 project_artifact=functest/$testbed/$res_build_date
24
25 # copy folder to artifact
26 if [ -d "$dir_result" ]; then
27     if [ "$(ls -A $dir_result)" ]; then
28           echo "copy result files to artifact $project_artifact"
29           gsutil -m cp -r "$dir_result" gs://artifacts.opnfv.org/"$project_artifact"/
30
31           # delete local results
32           # should not be useful as the container is about to die...just in case
33           rm -Rf /home/opnfv/functest/results/*
34     else
35           echo "Result folder is empty"
36     fi
37 else
38     echo "No result folder found"
39 fi