Merge "jjb: move project-style to releng-defaults.yaml"
[releng.git] / jjb / apex / apex.yml
index 65f042f..f920c9b 100644 (file)
@@ -21,8 +21,6 @@
 
     node: opnfv-jump-1
 
-    project-type: freestyle
-
     logrotate:
         daysToKeep: 30
         numToKeep: 10
             refspec: '$GERRIT_REFSPEC'
             choosing-strategy: 'gerrit'
 
-    wrappers:
-        - ssh-agent-credentials:
-            user: '{ssh-credentials}'
-
     triggers:
         - gerrit:
             trigger-on:
@@ -76,6 +70,7 @@
 
     builders:
         - 'apex-build'
+        - 'apex-deploy-virtual'
         - 'apex-workspace-cleanup'
 
 - job-template:
@@ -87,8 +82,6 @@
 
     node: opnfv-jump-1
 
-    project-type: freestyle
-
     logrotate:
         daysToKeep: 30
         numToKeep: 40
             refspec: ''
             choosing-strategy: 'default'
 
-    wrappers:
-        - ssh-agent-credentials:
-            user: '{ssh-credentials}'
-
     triggers:
         - gerrit:
             trigger-on:
 
     builders:
         - 'apex-build'
+        - 'apex-deploy-virtual'
         - 'apex-workspace-cleanup'
 
 - job-template:
 
     disabled: false
 
-    project-type: freestyle
-
     logrotate:
         daysToKeep: '{build-days-to-keep}'
         numToKeep: '{build-num-to-keep}'
             refspec: ''
             branch: '{branch}'
 
-    wrappers:
-        - ssh-agent-credentials:
-            user: '{ssh-credentials}'
-
     triggers:
         - 'apex-{stream}'
 
     builders:
         - 'apex-build'
+        - 'apex-deploy-virtual'
         - 'apex-upload-artifact'
         - 'apex-workspace-cleanup'
+        - trigger-builds:
+          - project: 'functest-apex-{stream}'
+            block: true
+            block-thresholds:
+                build-step-failure-threshold: 'never'
+                failure-threshold: 'never'
+                unstable-threshold: 'FAILURE'
 
 ########################
 # parameter macros
             # start the build
             cd $WORKSPACE/ci
             ./build.sh $FLAGS -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
+            RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
             # list the contents of BUILD_OUTPUT directory
             ls -al $BUILD_DIRECTORY
             # save information regarding artifact into file
                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
+                echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
+                echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
+                echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
                 echo "OPNFV_BUILD_URL=$BUILD_URL"
             ) > $WORKSPACE/opnfv.properties
             echo
 
             # upload artifact and additional files to google storage
             gsutil cp $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
+            gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
+            gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > 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
 
             echo
             echo "--------------------------------------------------------"
             echo "Done!"
-            echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
+            echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
+            echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
+
+- builder:
+    name: 'apex-deploy-virtual'
+    builders:
+        - shell: |
+            #!/bin/bash
+            set -o errexit
+            set -o nounset
+            set -o pipefail
+
+            # log info to console
+            echo "Starting the Apex virtual deployment."
+            echo "--------------------------------------------------------"
+            echo
 
+            # source the file so we get OPNFV vars
+            source opnfv.properties
+            RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
+
+            # update / install the new rpm
+            if rpm -q opnfv-apex > /dev/null; then
+               if sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
+                   sudo yum downgrade -y $RPM_INSTALL_PATH;
+               fi
+            else
+               sudo yum install -y $RPM_INSTALL_PATH;
+            fi
+
+            # cleanup virtual machines before we start
+            sudo opnfv-clean
+            # initiate virtual deployment
+            sudo opnfv-deploy -v
+
+            echo
+            echo "--------------------------------------------------------"
+            echo "Done!"
 
 #######################
 # trigger macros