Add template for nodejs jobs 45/40745/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 23 Jun 2016 02:23:55 +0000 (22:23 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 23 Jun 2016 02:30:00 +0000 (22:30 -0400)
Also add some documentation about the python and node verify jobs.

Change-Id: I92b1c6072b22402042dda04117b8931cab49e249
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
docs/jenkins.rst
jjb/releng-templates.yaml
jjb/spectrometer/spectrometer-jobs.yaml

index 70fb6c91e1606a615825313deca6f4e335db486c..49a859a1fa93f1aa06f4db6e84afb520f57f7445 100644 (file)
@@ -708,6 +708,29 @@ The **revalidate** trigger is useful in cases where a project's verify job
 passed however validate failed due to infra problems or intermittent issues.
 It will retrigger just the validate-autorelease job.
 
+Python Verify Job
+^^^^^^^^^^^^^^^^^
+
+Trigger: **recheck** | **revalidate**
+
+This job template can be used by a project that is Python based. It simply
+installs a python virtualenv and uses tox to run tests. When using the template
+you need to provide a {toxdir} which is the path relative to the root of the
+project repo containing the tox.ini file.
+
+Node Verify Job
+^^^^^^^^^^^^^^^^^
+
+Trigger: **recheck** | **revalidate**
+
+This job template can be used by a project that is NodeJS based. It simply
+installs a python virtualenv and uses that to install nodeenv which is then
+used to install another virtualenv for nodejs. It then calls **npm install**
+and **npm test** to run the unit tests. When using this template you need to
+provide a {nodedir} and {nodever} containing the directory relative to the
+project root containing the nodejs package.json and version of node you wish to
+run tests with.
+
 Basic Job Configuration
 -----------------------
 
index c39080eca03880b80cf34e89f865d54204345a06..753e1774fcc74296b58c5afb43ff701e8cb8d574 100644 (file)
         - email-notification:
             email-prefix: '[releng]'
 
+# Python Related
+
 - job-template:
     name: '{name}-verify-python-{stream}'
 
     publishers:
         - email-notification:
             email-prefix: '[{project}]'
+
+# Node related
+
+- job-template:
+    name: '{name}-verify-node-{stream}'
+
+    # Job template for python verify jobs
+    #
+    # The purpose of this job template is to run node tests for projects using
+    # this template. It uses python virtualenv to install nodeenv and create a
+    # virtualenv for nodejs.
+    #
+    # Required Variables:
+    #     stream:    release stream (eg. stable-lithium or beryllium)
+    #     branch:    git branch (eg. stable/lithium or master)
+    #     nodedir:   directory of nodejs project to run node test against
+    #     nodever:   version of node to install in virtualenv
+
+    project-type: freestyle
+    node: dynamic_verify
+    concurrent: true
+
+    logrotate:
+        daysToKeep: '7'
+        numToKeep: '-1'
+        artifactDaysToKeep: '-1'
+        artifactNumToKeep: '-1'
+
+    parameters:
+        - project-parameter:
+            project: '{project}'
+        - gerrit-parameters:
+            project: '{project}'
+            branch: '{branch}'
+            refspec: 'refs/heads/{branch}'
+
+    scm:
+        - git:
+            credentials-id: '{ssh-credentials}'
+            url: '$GIT_BASE'
+            basedir: 'repo'
+            refspec: '$GERRIT_REFSPEC'
+            branches:
+                - 'origin/$GERRIT_BRANCH'
+            skip-tag: true
+            choosing-strategy: 'gerrit'
+
+    wrappers:
+        - build-timeout
+        - ssh-agent-credentials:
+            users:
+                - '{ssh-credentials}'
+
+    triggers:
+        - gerrit:
+            server-name: 'OpenDaylight'
+            trigger-on:
+                - patchset-created-event:
+                    exclude-drafts: 'true'
+                    exclude-trivial-rebase: 'false'
+                    exclude-no-code-change: 'true'
+                - draft-published-event
+                - comment-added-contains-event:
+                    comment-contains-value: 'recheck'
+                - comment-added-contains-event:
+                    comment-contains-value: 'reverify'
+            projects:
+              - project-compare-type: 'ANT'
+                project-pattern: '{project}'
+                branches:
+                  - branch-compare-type: 'ANT'
+                    branch-pattern: '**/{branch}'
+                file-paths:
+                    - compare-type: ANT
+                      pattern: '{nodedir}/**'
+
+    builders:
+        - shell: |
+            #!/bin/bash
+            # Prepare Python
+            virtualenv $WORKSPACE/venv-python
+            source $WORKSPACE/venv-python/bin/activate
+            pip install --upgrade pip
+            pip install --upgrade tox argparse nodeenv
+            pip freeze
+
+            # Prepare node
+            nodeenv --node={nodever} --prebuilt $WORKSPACE/venv-node
+            source $WORKSPACE/venv-node/bin/activate
+            cd $WORKSPACE/repo/{nodedir}
+            npm install
+            npm test
+
+    publishers:
+        - email-notification:
+            email-prefix: '[{project}]'
index 8179720eb9bd7a982d69604e0a94b46c87a4d7a0..880c616b8997b7bbd89d1342d8e370bedacdb8f4 100644 (file)
@@ -2,6 +2,7 @@
     name: spectrometer
     jobs:
         - '{name}-merge-rtd-{stream}'
+        - '{name}-verify-node-{stream}'
         - '{name}-verify-python-{stream}'
 
     stream:
@@ -11,3 +12,5 @@
     project: 'spectrometer'
     rtdproject: 'opendaylight-spectrometer'
     toxdir: server
+    nodedir: web
+    nodever: 4.4.5