kvmfornfv: Improve patch verification jobs 39/17839/3
authorFatih Degirmenci <fatih.degirmenci@ericsson.com>
Fri, 29 Jul 2016 19:10:32 +0000 (21:10 +0200)
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>
Mon, 1 Aug 2016 07:49:36 +0000 (09:49 +0200)
This change
- changes the kvmfornfv-verify job to multijob so job abortion works when a new
  patch for the same change arrives
- creates 2 phase jobs for patchset verification, build and test
- enables artifact upload and download

Change-Id: I9de85e2f223e83e2256aaba831b88b0a879962b5
Signed-off-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com>
jjb/kvmfornfv/kvmfornfv-download-artifact.sh [new file with mode: 0755]
jjb/kvmfornfv/kvmfornfv-test.sh [new file with mode: 0755]
jjb/kvmfornfv/kvmfornfv-upload-artifact.sh [new file with mode: 0755]
jjb/kvmfornfv/kvmfornfv.yml
jjb/opnfv/slave-params.yml

diff --git a/jjb/kvmfornfv/kvmfornfv-download-artifact.sh b/jjb/kvmfornfv/kvmfornfv-download-artifact.sh
new file mode 100755 (executable)
index 0000000..24a5e45
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+if [[ "$JOB_TYPE" == "verify" ]]; then
+    echo "Downloading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
+    GS_URL="gs://artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
+else
+    echo "Artifact download is not enabled for $JOB_TYPE jobs"
+    exit 1
+fi
+
+/bin/mkdir -p $WORKSPACE/build_output
+gsutil cp -r $GS_URL/* $WORKSPACE/build_output > $WORKSPACE/gsutil.log 2>&1
+
+echo "--------------------------------------------------------"
+ls -al $WORKSPACE/build_output
+echo "--------------------------------------------------------"
+
+echo "Downloaded artifacts!"
diff --git a/jjb/kvmfornfv/kvmfornfv-test.sh b/jjb/kvmfornfv/kvmfornfv-test.sh
new file mode 100755 (executable)
index 0000000..7a47f9a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+ls -al $WORKSPACE/build_output
diff --git a/jjb/kvmfornfv/kvmfornfv-upload-artifact.sh b/jjb/kvmfornfv/kvmfornfv-upload-artifact.sh
new file mode 100755 (executable)
index 0000000..8139456
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [[ "$JOB_NAME" =~ (verify|merge|daily|weekly) ]]; then
+    JOB_TYPE=${BASH_REMATCH[0]}
+else
+    echo "Unable to determine job type!"
+    exit 1
+fi
+
+if [[ "$JOB_TYPE" == "verify" ]]; then
+    echo "Uploding artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
+    GS_URL="gs://artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
+else
+    echo "Artifact upload is not enabled for $JOB_TYPE jobs"
+    exit 1
+fi
+
+gsutil cp -r $WORKSPACE/build_output $GS_URL > $WORKSPACE/gsutil.log 2>&1
+gsutil -m setmeta -r \
+    -h "Cache-Control:private, max-age=0, no-transform" \
+    $GS_URL > /dev/null 2>&1
+
+gsutil ls $GS_URL > /dev/null 2>&1
+if [[ $? -ne 0 ]]; then
+    echo "Problem while uploading artifacts!"
+    echo "Check log $WORKSPACE/gsutil.log on $NODE_NAME"
+    exit 1
+fi
+echo "Uploaded artifacts!"
index aa8b645..c5c122e 100644 (file)
@@ -3,21 +3,47 @@
 
     project: '{name}'
 
-    jobs:
-        - 'kvmfornfv-verify-{stream}'
-        - 'kvmfornfv-merge-{stream}'
-
     stream:
         - master:
             branch: '{stream}'
             gs-pathname: ''
+            disabled: false
         - brahmaputra:
             branch: 'stable/{stream}'
             gs-pathname: '/{stream}'
+            disabled: true
 
+#####################################
+# patch verification phases
+#####################################
+    phase:
+        - 'build':
+            slave-label: 'opnfv-build-ubuntu'
+        - 'test':
+            slave-label: 'intel-pod1'
+#####################################
+# patch verification phases
+#####################################
+    jobs:
+        - 'kvmfornfv-verify-{stream}'
+        - 'kvmfornfv-verify-{phase}-{stream}'
+        - 'kvmfornfv-merge-{stream}'
+#####################################
+# job templates
+#####################################
 - job-template:
     name: 'kvmfornfv-verify-{stream}'
 
+    disabled: '{obj:disabled}'
+
+    concurrent: true
+
+    properties:
+        - throttle:
+            enabled: true
+            max-total: 3
+            option: 'project'
+
     parameters:
         - project-parameter:
             project: '{project}'
                     branch-pattern: '**/{branch}'
 
     builders:
-        - shell:
-            !include-raw: ./kvmfornfv-build.sh
+        - description-setter:
+            description: "Built on $NODE_NAME"
+        - multijob:
+            name: build
+            condition: SUCCESSFUL
+            projects:
+                - name: 'kvmfornfv-verify-build-{stream}'
+                  current-parameters: false
+                  predefined-parameters: |
+                    GERRIT_BRANCH=$GERRIT_BRANCH
+                    GERRIT_REFSPEC=$GERRIT_REFSPEC
+                    GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                  node-parameters: false
+                  kill-phase-on: FAILURE
+                  abort-all-job: true
+        - multijob:
+            name: test
+            condition: SUCCESSFUL
+            projects:
+                - name: 'kvmfornfv-verify-test-{stream}'
+                  current-parameters: false
+                  predefined-parameters: |
+                    GERRIT_BRANCH=$GERRIT_BRANCH
+                    GERRIT_REFSPEC=$GERRIT_REFSPEC
+                    GERRIT_CHANGE_NUMBER=$GERRIT_CHANGE_NUMBER
+                  node-parameters: false
+                  kill-phase-on: FAILURE
+                  abort-all-job: true
+
+- job-template:
+    name: 'kvmfornfv-verify-{phase}-{stream}'
+
+    disabled: '{obj:disabled}'
+
+    concurrent: true
+
+    scm:
+        - gerrit-trigger-scm:
+            credentials-id: '{ssh-credentials}'
+            refspec: '$GERRIT_REFSPEC'
+            choosing-strategy: 'gerrit'
+
+    wrappers:
+        - ssh-agent-credentials:
+            users:
+                - '{ssh-credentials}'
+        - timeout:
+            timeout: 360
+            fail: true
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameter:
+            branch: '{branch}'
+        - '{slave-label}-defaults'
+
+    builders:
+        - description-setter:
+            description: "Built on $NODE_NAME"
+        - '{project}-verify-{phase}-macro'
 
 - job-template:
     name: 'kvmfornfv-merge-{stream}'
         - gerrit-parameter:
             branch: '{branch}'
         - 'opnfv-build-ubuntu-defaults'
+        - 'kvmfornfv-defaults':
+            gs-pathname: '{gs-pathname}'
 
     scm:
         - gerrit-trigger-scm:
     builders:
         - shell:
             !include-raw: ./kvmfornfv-build.sh
+#####################################
+# builder macros
+#####################################
+- builder:
+    name: 'kvmfornfv-verify-build-macro'
+    builders:
+        - shell:
+            !include-raw: ./kvmfornfv-build.sh
+        - shell:
+            !include-raw: ./kvmfornfv-upload-artifact.sh
+- builder:
+    name: 'kvmfornfv-verify-test-macro'
+    builders:
+        - shell:
+            !include-raw: ./kvmfornfv-download-artifact.sh
+        - shell:
+            !include-raw: ./kvmfornfv-test.sh
+#####################################
+# parameter macros
+#####################################
+- parameter:
+    name: 'kvmfornfv-defaults'
+    parameters:
+        - string:
+            name: GS_URL
+            default: artifacts.opnfv.org/$PROJECT{gs-pathname}
+            description: "URL to Google Storage."
index 7b99830..a75fe11 100644 (file)
             name: GIT_BASE
             default: https://gerrit.opnfv.org/gerrit/$PROJECT
             description: 'Git URL to use on this Jenkins Slave'
+- parameter:
+    name: 'intel-pod1-defaults'
+    parameters:
+        - node:
+            name: SLAVE_NAME
+            description: 'Slave name on Jenkins'
+            allowed-slaves:
+                - intel-pod1
+            default-slaves:
+                - intel-pod1
+        - string:
+            name: GIT_BASE
+            default: https://gerrit.opnfv.org/gerrit/$PROJECT
+            description: 'Git URL to use on this Jenkins Slave'
 - parameter:
     name: 'intel-pod2-defaults'
     parameters: