From 5a7a6a6c48511dd8d53defe64609edc88d4999bb Mon Sep 17 00:00:00 2001
From: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
Date: Tue, 17 Nov 2015 23:33:43 +0100
Subject: Upload and download Fuel ISOs in scope of fuel-merge jobs

This is the first step towards enabling virtual deployments for Fuel
merge jobs. This change introduces
- storing the ISOs built by the merge jobs on OPNFV Artifact Repository
- downloading ISOs built by the merge jobs for virtual deployments

Once this gets merged, a second change will be sent for enabling the virtual
deployments using downloaded ISO.

Change-Id: I726f58d914c7c216e1ffe626c2ca250f56d08222
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
---
 jjb/fuel/fuel-build.sh             |  7 ++++++-
 jjb/fuel/fuel-download-artifact.sh |  9 +++++++--
 jjb/fuel/fuel-upload-artifact.sh   |  6 +++++-
 jjb/fuel/fuel.yml                  | 16 ++++++++--------
 4 files changed, 26 insertions(+), 12 deletions(-)

(limited to 'jjb')

diff --git a/jjb/fuel/fuel-build.sh b/jjb/fuel/fuel-build.sh
index 178a50c68..63a62f497 100755
--- a/jjb/fuel/fuel-build.sh
+++ b/jjb/fuel/fuel-build.sh
@@ -12,7 +12,12 @@ echo
 [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
 
 # set OPNFV_ARTIFACT_VERSION
-export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
+if [[ $GERRIT_EVENT_TYPE = "change-merged" ]]; then
+    echo "Building Fuel ISO for a merged change"
+    OPNFV_ARTIFACT_VERSION=$(gerrit-$GERRIT_CHANGE_NUMBER)
+else
+    OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
+fi
 
 # start the build
 cd $WORKSPACE/$INSTALLER/ci
diff --git a/jjb/fuel/fuel-download-artifact.sh b/jjb/fuel/fuel-download-artifact.sh
index 6eb1ba463..7ebc0d6d0 100755
--- a/jjb/fuel/fuel-download-artifact.sh
+++ b/jjb/fuel/fuel-download-artifact.sh
@@ -3,8 +3,13 @@ set -o errexit
 set -o nounset
 set -o pipefail
 
-# get the latest.properties file in order to get info regarding latest artifact
-curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
+if [[ $GERRIT_EVENT_TYPE = "change-merged" ]]; then
+    # get the properties file for the Fuel ISO built for a merged change
+    curl -s -o $WORKSPACE/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties http://$GS_URL/latest.properties
+else
+    # get the latest.properties file in order to get info regarding latest artifact
+    curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
+fi
 
 # check if we got the file
 [[ -f latest.properties ]] || exit 1
diff --git a/jjb/fuel/fuel-upload-artifact.sh b/jjb/fuel/fuel-upload-artifact.sh
index 3b700c649..a4bf32cf4 100755
--- a/jjb/fuel/fuel-upload-artifact.sh
+++ b/jjb/fuel/fuel-upload-artifact.sh
@@ -14,7 +14,11 @@ source $WORKSPACE/opnfv.properties
 # 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
 gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
-gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
+if [[ ! $GERRIT_EVENT_TYPE = "change-merged" ]]; then
+    gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
+else
+    echo "Uploaded Fuel ISO for a merged change"
+fi
 
 echo
 echo "--------------------------------------------------------"
diff --git a/jjb/fuel/fuel.yml b/jjb/fuel/fuel.yml
index 1f53454e3..1625124f6 100644
--- a/jjb/fuel/fuel.yml
+++ b/jjb/fuel/fuel.yml
@@ -222,10 +222,10 @@
     builders:
         - shell:
             !include-raw ./fuel-build.sh
-#        - shell:
-#            !include-raw ./fuel-upload-artifact.sh
-#        - shell:
-#            !include-raw ./fuel-workspace-cleanup.sh
+        - shell:
+            !include-raw ./fuel-upload-artifact.sh
+        - shell:
+            !include-raw ./fuel-workspace-cleanup.sh
 
 - job-template:
     name: 'fuel-merge-virtual-deploy-{stream}'
@@ -281,12 +281,12 @@
             dependency-jobs: 'fuel-merge-build-{stream}'
 
     builders:
-#        - shell:
-#            !include-raw ./fuel-download-artifact.sh
+        - shell:
+            !include-raw ./fuel-download-artifact.sh
         - shell:
             !include-raw ./fuel-virtual-deploy.sh
-#        - shell:
-#            !include-raw ./fuel-workspace-cleanup.sh
+        - shell:
+            !include-raw ./fuel-workspace-cleanup.sh
 
 - job-template:
     name: 'fuel-daily-{stream}'
-- 
cgit