5 if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
6 JOB_TYPE=${BASH_REMATCH[0]}
8 echo "Unable to determine job type!"
14 OPNFV_ARTIFACT_VERSION="gerrit-$GERRIT_CHANGE_NUMBER"
15 GS_UPLOAD_LOCATION="gs://artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
16 echo "Removing outdated artifacts produced for the previous patch for the change $GERRIT_CHANGE_NUMBER"
17 gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1 && gsutil rm -r $GS_UPLOAD_LOCATION
18 echo "Uploading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
21 echo "Uploading daily artifacts This could take some time..."
22 OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
23 GS_UPLOAD_LOCATION="gs://$GS_URL/$OPNFV_ARTIFACT_VERSION"
24 GS_LOG_LOCATION="gs://$GS_URL/logs-$(date -u +"%Y-%m-%d")/
27 echo "Artifact upload is not enabled for $JOB_TYPE jobs"
31 # save information regarding artifacts into file
33 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
34 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
35 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
36 echo "OPNFV_ARTIFACT_URL=$GS_UPLOAD_LOCATION"
37 echo "OPNFV_BUILD_URL=$BUILD_URL"
38 ) > $WORKSPACE/opnfv.properties
39 source $WORKSPACE/opnfv.properties
42 if [[ "$PHASE" == "build" ]]; then
43 gsutil cp -r $WORKSPACE/build_output/* $GS_UPLOAD_LOCATION > $WORKSPACE/gsutil.log 2>&1
44 gsutil -m setmeta -r \
45 -h "Cache-Control:private, max-age=0, no-transform" \
46 $GS_UPLOAD_LOCATION > /dev/null 2>&1
48 if [[ "$JOB_TYPE" == "daily" ]]; then
49 log_dir=$WORKSPACE/build_output/log
50 if [[ -d "$log_dir" ]]; then
51 #Uploading logs to artifacts
52 echo "Uploading artifacts for future debugging needs...."
53 gsutil cp -r $WORKSPACE/build_output/log-*.tar.gz $GS_LOG_LOCATION > $WORKSPACE/gsutil.log 2>&1
55 echo "No test logs/artifacts available for uploading"
60 # upload metadata file for the artifacts built by daily job
61 if [[ "$JOB_TYPE" == "daily" ]]; then
62 gsutil cp $WORKSPACE/opnfv.properties $GS_UPLOAD_LOCATION/opnfv.properties > $WORKSPACE/gsutil.log 2>&1
63 gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > $WORKSPACE/gsutil.log 2>&1
64 gsutil -m setmeta -r \
65 -h "Cache-Control:private, max-age=0, no-transform" \
66 $GS_UPLOAD_LOCATION/opnfv.properties \
67 gs://$GS_URL/latest.properties > /dev/null 2>&1
70 gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1
71 if [[ $? -ne 0 ]]; then
72 echo "Problem while uploading artifacts!"
73 echo "Check log $WORKSPACE/gsutil.log on $NODE_NAME"
76 echo "Uploaded artifacts!"