Merge "Add CORD Helm chart repository to lint job"
diff --git a/jjb/shell/xos-unit.sh b/jjb/shell/xos-unit.sh
new file mode 100644
index 0000000..1e19cf1
--- /dev/null
+++ b/jjb/shell/xos-unit.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+# Copyright 2018-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# xos-unit.sh - perform a unit test on XOS or synchronizers
+set -e -o pipefail
+
+# when not running under Jenkins, use current dir as workspace, and 'xos' as GERRIT_PROJECT
+WORKSPACE=${WORKSPACE:-.}
+GERRIT_PROJECT=${GERRIT_PROJECT:-xos}
+
+# create python virtual env
+export XOS_DIR=${WORKSPACE}/cord/orchestration/xos
+$XOS_DIR/scripts/setup_venv.sh
+source venv-xos/bin/activate
+
+# find the path to the project that is checked out
+PROJECT_PATH=$(xmllint --xpath "string(//project[@name=\"$GERRIT_PROJECT\"]/@path)" cord/.repo/manifest.xml)
+
+if [ "$GERRIT_PROJECT" = 'xos' ] ; then
+  pushd "$WORKSPACE/cord/$PROJECT_PATH"
+else
+  pushd "$WORKSPACE/cord/$PROJECT_PATH/xos"
+fi
+
+echo "Performing nose2 tests"
+nose2 --verbose --with-coverage --coverage-report xml --coverage-report term --junit-xml
+popd
+
diff --git a/jjb/xos-unit.yaml b/jjb/xos-unit.yaml
index 74400e4..b5bd741 100644
--- a/jjb/xos-unit.yaml
+++ b/jjb/xos-unit.yaml
@@ -27,57 +27,35 @@
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
 
     scm:
-      - lf-infra-gerrit-scm:
-          git-url: '$GIT_URL/$GERRIT_PROJECT'
-          refspec: '$GERRIT_REFSPEC'
+      - cord-infra-gerrit-repo-scm:
+          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
           branch: '$GERRIT_BRANCH'
-          submodule-recursive: 'false'
-          choosing-strategy: gerrit
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          destination-dir: 'cord'
 
     node: 'ubuntu16.04-basebuild-1c-2g'
     project-type: freestyle
     concurrent: true
 
     builders:
-      - shell: |
-          #/usr/bin/env bash
-          BASEDIR=$(pwd)
+      - cord-infra-gerrit-repo-patch:
+          destination-dir: 'cord'
+          project: '$GERRIT_PROJECT'
+          change-number: '$GERRIT_CHANGE_NUMBER'
+          patchset-number: '$GERRIT_PATCHSET_NUMBER'
+      - shell: !include-raw-escape: shell/xos-unit.sh
 
-          # setup virtual env
-          virtualenv -q venv-xos --no-site-packages
-          source $BASEDIR/venv-xos/bin/activate
-          pip install --upgrade pip setuptools
+    publishers:
+      - junit:
+          results: "**/nose2-junit.xml"
+      - cobertura:
+          report-file: "**/coverage.xml"
+          targets:
+            - files:
+                healthy: 80
+                unhealthy: 0
+                failing: 0
+            - method:
+                healthy: 50
+                unhealthy: 0
+                failing: 0
 
-          # download changeset
-          mkdir cord && cd cord/
-          repo init -u https://gerrit.opencord.org/manifest -b $GERRIT_BRANCH
-          repo sync
-          repo download $GERRIT_PROJECT $GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER
-
-          # Install XOS dependencies
-          pip install nose2 requests_mock plyxproto jinja2 pattern astunparse pyyaml colorama
-          pip install pykwalify==1.6.1
-          pip install multistructlog==1.5
-          pip install networkx==1.11
-          pip install netaddr==0.7.19
-          pip install ipaddress==1.0.19
-          pip install grpcio==1.9.1
-          pip install grpcio-tools==1.9.1
-          pip install kafka==1.3.5
-          echo "Requirements Installed"
-
-          cd $BASEDIR/cord/orchestration/xos/lib/xos-util; python setup.py install; echo "xos-util Installed"
-          cd $BASEDIR/cord/orchestration/xos/lib/xos-config; python setup.py install; echo "xos-config Installed"
-          cd $BASEDIR/cord/orchestration/xos/lib/xos-genx; python setup.py install; echo "xos-genx Installed"
-
-          cd $BASEDIR/cord/orchestration/xos/xos/xos_client/xosapi; ln -s ../../../../../component/chameleon chameleon
-          cd $BASEDIR/cord/orchestration/xos/xos/xos_client; make; echo "xos-client Installed"
-
-          # Run the tests
-          if [ $GERRIT_PROJECT = 'xos' ] ; then
-            cd $BASEDIR
-          else
-            cd $BASEDIR/cord/orchestration/xos_services/$GERRIT_PROJECT/xos
-          fi
-          nose2 --verbose  --exclude-ignored-files