304d2cc34d1a6177983b2fca8f2ab76485dfb9c1
[releng.git] / jjb / functest / res-build.sh
1 #!/bin/bash
2 set -e
3 set -o pipefail
4
5 project="$(git remote -v | head -n1 | awk '{{print $2}}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')"
6 export PATH=$PATH:/usr/local/bin/
7
8 git_sha1="$(git rev-parse HEAD)"
9 res_build_date=$(date -u +"%Y-%m-%d_%H-%M-%S")
10
11 # set once, functe config file could be use to avoid such hardcoded path
12 dir_result="$HOME/functest/results"
13
14 # Several information are required: date and testbed
15 # date is generated by functest so on the artifact, the results shall be under functest/<testbed id>/date/
16 testbed="$(hostname)"
17 project_artifact=$project/$testbed/$res_build_date
18
19 # copy folder to artifact
20 if [ -d "$dir_result" ]; then
21     if [ "$(ls -A $dir_result)" ]; then
22           echo "copy result files to artifact $project_artifact"
23           gsutil cp -r "$dir_result" gs://artifacts.opnfv.org/"$project_artifact"/
24     else
25           echo "Result folder is empty"
26     fi
27 else
28     echo "No result folder found"
29 fi