Prepare backporting K8s security containers
[releng.git] / jjb / kvmfornfv / kvmfornfv-upload-artifact.sh
index c6b8005..91b6f44 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/bash
-set -o errexit
 set -o nounset
 
 if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
@@ -21,7 +20,7 @@ case "$JOB_TYPE" in
         echo "Uploading daily artifacts This could take some time..."
         OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
         GS_UPLOAD_LOCATION="gs://$GS_URL/$OPNFV_ARTIFACT_VERSION"
-        GS_LOG_LOCATION="gs://$GS_URL/logs-$(date -u +"%Y-%m-%d")/
+        GS_LOG_LOCATION="gs://$GS_URL/logs-$(date -u +"%Y-%m-%d")"/
         ;;
     *)
         echo "Artifact upload is not enabled for $JOB_TYPE jobs"
@@ -51,6 +50,13 @@ else
             #Uploading logs to artifacts
             echo "Uploading artifacts for future debugging needs...."
             gsutil cp -r $WORKSPACE/build_output/log-*.tar.gz $GS_LOG_LOCATION > $WORKSPACE/gsutil.log 2>&1
+            # verifying the logs uploaded by cyclictest daily test job
+            gsutil ls $GS_LOG_LOCATION > /dev/null 2>&1
+            if [[ $? -ne 0 ]]; then
+                echo "Problem while uploading logs to artifacts!"
+                echo "Check log $WORKSPACE/gsutil.log on $NODE_NAME"
+                exit 1
+            fi
         else
             echo "No test logs/artifacts available for uploading"
         fi
@@ -58,7 +64,7 @@ else
 fi
 
 # upload metadata file for the artifacts built by daily job
-if [[ "$JOB_TYPE" == "daily" ]]; then
+if [[ "$JOB_TYPE" == "daily" && "$PHASE" == "build" ]]; then
     gsutil cp $WORKSPACE/opnfv.properties $GS_UPLOAD_LOCATION/opnfv.properties > $WORKSPACE/gsutil.log 2>&1
     gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > $WORKSPACE/gsutil.log 2>&1
     gsutil -m setmeta -r \
@@ -67,10 +73,13 @@ if [[ "$JOB_TYPE" == "daily" ]]; then
         gs://$GS_URL/latest.properties > /dev/null 2>&1
 fi
 
-gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1
-if [[ $? -ne 0 ]]; then
-    echo "Problem while uploading artifacts!"
-    echo "Check log $WORKSPACE/gsutil.log on $NODE_NAME"
-    exit 1
+# verifying the artifacts uploading by verify/daily build job
+if [[ "$PHASE" == "build" ]]; then
+    gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1
+    if [[ $? -ne 0 ]]; then
+        echo "Problem while uploading artifacts!"
+        echo "Check log $WORKSPACE/gsutil.log on $NODE_NAME"
+        exit 1
+    fi
 fi
 echo "Uploaded artifacts!"