Basic CI integration for building Gluon packages 57/25757/4
authorGeorg Kunz <georg.kunz@ericsson.com>
Sat, 10 Dec 2016 15:40:11 +0000 (16:40 +0100)
committerGeorg Kunz <georg.kunz@ericsson.com>
Thu, 15 Dec 2016 19:59:59 +0000 (20:59 +0100)
This first iteration of CI integration aims at realizing a daily
build job which creates installable RPM from upstream Gluon master.

Change-Id: I5a722943850e27f4d0345a73b488cbd00244ac90
Signed-off-by: Georg Kunz <georg.kunz@ericsson.com>
jjb/netready/netready-gluon-build.sh [new file with mode: 0755]
jjb/netready/netready-upload-gluon-packages.sh [new file with mode: 0755]
jjb/netready/netready.yml

diff --git a/jjb/netready/netready-gluon-build.sh b/jjb/netready/netready-gluon-build.sh
new file mode 100755 (executable)
index 0000000..5904c84
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+echo "Building Gluon packages."
+echo "------------------------"
+echo
+
+if [ "$ARTIFACT_VERSION" == "daily" ]; then
+   export OPNFV_ARTIFACT_VERSION=$(echo $(date -u +"%Y%m%d"))
+fi
+
+# build all packages
+cd $WORKSPACE/ci
+./build-gluon-packages.sh
+
+# list the contents of BUILD_OUTPUT directory
+echo "Build Directory is ${BUILD_DIRECTORY}"
+echo "Build Directory Contents:"
+echo "---------------------------------------"
+ls -alR $BUILD_DIRECTORY
+
+# get version infos from Gluon from spec
+GLUON_VERSION=$(grep Version: $BUILD_DIRECTORY/rpm_specs/gluon.spec | awk '{ print $2 }')
+GLUON_RELEASE=$(grep 'define release' $BUILD_DIRECTORY/rpm_specs/gluon.spec | awk '{ print $3 }')_$OPNFV_ARTIFACT_VERSION
+
+ARTIFACT_NAME=gluon-$GLUON_VERSION-$GLUON_RELEASE.noarch.rpm
+ARTIFACT_PATH=$BUILD_DIRECTORY/noarch/$ARTIFACT_NAME
+
+echo "Writing opnfv.properties file"
+# save information regarding artifact 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_URL/$ARTIFACT_NAME"
+  echo "OPNFV_ARTIFACT_SHA512SUM=$(sha512sum $ARTIFACT_PATH | cut -d' ' -f1)"
+  echo "OPNFV_BUILD_URL=$BUILD_URL"
+  echo "ARTIFACT_LIST=$ARTIFACT_PATH"
+) > $WORKSPACE/opnfv.properties
+
+echo "---------------------------------------"
+echo "Done!"
diff --git a/jjb/netready/netready-upload-gluon-packages.sh b/jjb/netready/netready-upload-gluon-packages.sh
new file mode 100755 (executable)
index 0000000..7c1e337
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+echo "Uploading Gluon packages"
+echo "--------------------------------------------------------"
+echo
+
+source $WORKSPACE/opnfv.properties
+
+for artifact in $ARTIFACT_LIST; do
+  echo "Uploading artifact: ${artifact}"
+  gsutil cp $artifact gs://$GS_URL/$(basename $artifact) > gsutil.$(basename $artifact).log
+  echo "Upload complete for ${artifact}"
+done
+
+gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log
+gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.properties.log
+
+echo "--------------------------------------------------------"
+echo "Upload done!"
+
+echo "Artifacts are not available as:"
+for artifact in $ARTIFACT_LIST; do
+  echo "http://$GS_URL/$(basename $artifact)"
+done
index cc6769e..181af3a 100644 (file)
@@ -5,16 +5,13 @@
 
     jobs:
         - 'netready-verify-{stream}'
+        - 'netready-build-gluon-packages-daily-{stream}'
 
     stream:
         - master:
             branch: '{stream}'
             gs-pathname: ''
             disabled: false
-        - colorado:
-            branch: 'stable/{stream}'
-            gs-pathname: '/{stream}'
-            disabled: false
 
 - job-template:
     name: 'netready-verify-{stream}'
     builders:
         - shell: |
             echo "Nothing to verify!"
+
+
+
+- job-template:
+    name: 'netready-build-gluon-packages-daily-{stream}'
+
+    disabled: false
+
+    concurrent: true
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: '{branch}'
+        - 'opnfv-build-ubuntu-defaults'
+
+    scm:
+        - git-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: ''
+            branch: '{branch}'
+
+    builders:
+        - 'netready-gluon-build'
+
+    triggers:
+        - timed: '@midnight'
+
+
+########################
+# builder macros
+########################
+
+- builder:
+    name: 'netready-gluon-build'
+    builders:
+        - shell:
+            !include-raw: ./netready-gluon-build.sh
+        - shell:
+            !include-raw: ./netready-upload-gluon-packages.sh
+
+
+########################
+# parameter macros
+########################
+
+- parameter:
+    name: netready-parameter
+    parameters:
+        - string:
+            name: BUILD_DIRECTORY
+            default: $WORKSPACE/build
+            description: "Directory where the build artifact will be located upon the completion of the build."
+        - string:
+            name: GS_URL
+            default: artifacts.opnfv.org/$PROJECT{gs-pathname}
+            description: "URL to Google Storage."