X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fkvmfornfv%2Fkvmfornfv-upload-artifact.sh;h=6f8fff3ff9c279b0e3b55f608d13d51f148d8566;hb=855b5927c98ea67fda0cec1fedd76aea66b96414;hp=190ab4b4d89e29bf6f3f704733852d19fba1c775;hpb=48e9188db830c825c5212969e3cf85c055002f3c;p=releng.git diff --git a/jjb/kvmfornfv/kvmfornfv-upload-artifact.sh b/jjb/kvmfornfv/kvmfornfv-upload-artifact.sh index 190ab4b4d..6f8fff3ff 100755 --- a/jjb/kvmfornfv/kvmfornfv-upload-artifact.sh +++ b/jjb/kvmfornfv/kvmfornfv-upload-artifact.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -o errexit +set -o nounset if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then JOB_TYPE=${BASH_REMATCH[0]} @@ -9,11 +11,14 @@ fi case "$JOB_TYPE" in verify) - echo "Uploading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..." + OPNFV_ARTIFACT_VERSION="gerrit-$GERRIT_CHANGE_NUMBER" GS_UPLOAD_LOCATION="gs://artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER" + echo "Removing outdated artifacts produced for the previous patch for the change $GERRIT_CHANGE_NUMBER" + gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1 && gsutil rm -r $GS_UPLOAD_LOCATION + echo "Uploading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..." ;; daily) - echo "Uploding daily artifacts This could take some time..." + 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" ;; @@ -22,11 +27,32 @@ case "$JOB_TYPE" in exit 1 esac -gsutil cp -r $WORKSPACE/build_output $GS_UPLOAD_LOCATION > $WORKSPACE/gsutil.log 2>&1 +# save information regarding artifacts into file +( + echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION" + echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)" + echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)" + echo "OPNFV_ARTIFACT_URL=$GS_UPLOAD_LOCATION" + echo "OPNFV_BUILD_URL=$BUILD_URL" +) > $WORKSPACE/opnfv.properties +source $WORKSPACE/opnfv.properties + +# upload artifacts +gsutil cp -r $WORKSPACE/build_output/* $GS_UPLOAD_LOCATION > $WORKSPACE/gsutil.log 2>&1 gsutil -m setmeta -r \ -h "Cache-Control:private, max-age=0, no-transform" \ $GS_UPLOAD_LOCATION > /dev/null 2>&1 +# upload metadata file for the artifacts built by daily job +if [[ "$JOB_TYPE" == "daily" ]]; 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 \ + -h "Cache-Control:private, max-age=0, no-transform" \ + $GS_UPLOAD_LOCATION/opnfv.properties \ + 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!"