kvmfornfv: Downloading sha512sum file of the guest image.
[releng.git] / jjb / kvmfornfv / kvmfornfv-download-artifact.sh
index 24a5e45..ea37eb2 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
 
 if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
     JOB_TYPE=${BASH_REMATCH[0]}
@@ -7,19 +10,30 @@ else
     exit 1
 fi
 
-if [[ "$JOB_TYPE" == "verify" ]]; then
-    echo "Downloading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
-    GS_URL="gs://artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
-else
-    echo "Artifact download is not enabled for $JOB_TYPE jobs"
-    exit 1
-fi
+# do stuff differently based on the job type
+case "$JOB_TYPE" in
+    verify)
+        echo "Downloading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
+        GS_UPLOAD_LOCATION="gs://artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
+        ;;
+    daily)
+        gsutil cp gs://$GS_URL/latest.properties $WORKSPACE/latest.properties
+        source $WORKSPACE/latest.properties
+        GS_UPLOAD_LOCATION=$OPNFV_ARTIFACT_URL
+        echo "Downloading artifacts from $GS_UPLOAD_LOCATION for daily run. This could take some time..."
+        ;;
+    *)
+        echo "Artifact download is not enabled for $JOB_TYPE jobs"
+        exit 1
+esac
 
+GS_GUESTIMAGE_LOCATION="gs://artifacts.opnfv.org/$PROJECT/guest-image"
 /bin/mkdir -p $WORKSPACE/build_output
-gsutil cp -r $GS_URL/* $WORKSPACE/build_output > $WORKSPACE/gsutil.log 2>&1
+gsutil cp -r $GS_UPLOAD_LOCATION/* $WORKSPACE/build_output > $WORKSPACE/gsutil.log 2>&1
+gsutil cp $GS_GUESTIMAGE_LOCATION/guest1.sha512 $WORKSPACE/build_output > $WORKSPACE/gsutil.log 2>&1
 
 echo "--------------------------------------------------------"
 ls -al $WORKSPACE/build_output
 echo "--------------------------------------------------------"
-
+echo
 echo "Downloaded artifacts!"