merge GIT_BRANCH and GERRIT_BRANCH into BRANCH
[releng.git] / jjb / fuel / fuel-upload-artifact.sh
index cf74eb4..d1ac350 100755 (executable)
@@ -7,7 +7,6 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-set -o nounset
 set -o pipefail
 
 # check if we built something
@@ -17,14 +16,54 @@ if [ -f $WORKSPACE/.noupload ]; then
     exit 0
 fi
 
-# log info to console
-echo
-echo "Uploading the $INSTALLER_TYPE artifact. This could take some time..."
-echo
-
 # source the opnfv.properties to get ARTIFACT_VERSION
 source $WORKSPACE/opnfv.properties
 
+nfsstore () {
+# storing ISOs for verify & merge jobs will be done once we get the disk array
+if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
+    # store ISO locally on NFS first
+    ISOSTORE="/iso_mount/opnfv_ci/${BRANCH##*/}"
+    if [[ -d "$ISOSTORE" ]]; then
+        # remove all but most recent 5 ISOs first to keep iso_mount clean & tidy
+        cd $ISOSTORE
+        ls -tp | grep -v '/' | tail -n +6 | xargs -d '\n' /bin/rm -f --
+
+        # store ISO
+        echo "Storing $INSTALLER_TYPE artifact on NFS..."
+        /bin/cp -f $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso \
+            $ISOSTORE/opnfv-$OPNFV_ARTIFACT_VERSION.iso
+    fi
+fi
+}
+
+importkey () {
+# clone releng repository
+echo "Cloning releng repository..."
+[ -d releng ] && rm -rf releng
+git clone https://gerrit.opnfv.org/gerrit/releng $WORKSPACE/releng/ &> /dev/null
+#this is where we import the siging key
+if [ -f $WORKSPACE/releng/utils/gpg_import_key.sh ]; then
+  source $WORKSPACE/releng/utils/gpg_import_key.sh
+fi
+}
+
+signiso () {
+gpg2 -vvv --batch --yes --no-tty \
+  --default-key opnfv-helpdesk@rt.linuxfoundation.org  \
+  --passphrase besteffort \
+  --detach-sig $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso
+
+gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso.sig gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso.sig
+echo "ISO signature Upload Complete!"
+}
+
+uploadiso () {
+# log info to console
+echo "Uploading $INSTALLER_TYPE artifact. This could take some time..."
+echo
+
+cd $WORKSPACE
 # upload artifact and additional files to google storage
 gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso \
     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
@@ -65,3 +104,15 @@ echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
 echo
 echo "--------------------------------------------------------"
 echo
+}
+
+nfsstore
+
+if [[ "$JOB_NAME" =~ merge ]]; then
+    uploadiso
+elif [[ "$JOB_NAME" =~ build ]]; then
+    importkey
+    signiso
+    uploadiso
+fi
+