c8bdb9c7210e0c0b598362b367a034921f9c3672
[releng.git] / jjb / kvmfornfv / kvmfornfv-download-artifact.sh
1 #!/bin/bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5
6 if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
7     JOB_TYPE=${BASH_REMATCH[0]}
8 else
9     echo "Unable to determine job type!"
10     exit 1
11 fi
12
13 # do stuff differently based on the job type
14 case "$JOB_TYPE" in
15     verify)
16         echo "Downloading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
17         GS_UPLOAD_LOCATION="gs://artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
18         ;;
19     daily)
20         gsutil cp gs://$GS_URL/latest.properties $WORKSPACE/latest.properties
21         source $WORKSPACE/latest.properties
22         GS_UPLOAD_LOCATION=$OPNFV_ARTIFACT_URL
23         echo "Downloading artifacts from $GS_UPLOAD_LOCATION for daily run. This could take some time..."
24         ;;
25     *)
26         echo "Artifact download is not enabled for $JOB_TYPE jobs"
27         exit 1
28 esac
29
30 /bin/mkdir -p $WORKSPACE/build_output
31 gsutil cp -r $GS_UPLOAD_LOCATION/* $WORKSPACE/build_output > $WORKSPACE/gsutil.log 2>&1
32
33 echo "--------------------------------------------------------"
34 ls -al $WORKSPACE/build_output
35 echo "--------------------------------------------------------"
36 echo
37 echo "Downloaded artifacts!"