Merge "triggering voltha-bbsim repo for voltha-atest-bbsim"
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index 3298eba..f6737a5 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -80,7 +80,7 @@
 
     # matching repos that should be version tagged by the version-tag job
     # (basically the same as imagebuilder projects + helm charts + tools
-    version-tag-projects-regexp: '^(xos.*|helm-charts|automation-tools|cord-tester|chameleon|rcord|mcord|ecord|acordion|addressmanager|epc-service|exampleservice|fabric|fabric-crossconnect|globalxos|hippie-oss|hss_db|hypercache|internetemulator|kubernetes-service|monitoring|olt-service|onos-service|openstack|progran|sdn-controller|simpleexampleservice|templateservice|vEE|vEG|vBBU|venb|vHSS|vMME|vnaas|vPGWC|vPGWU|vrouter|vsg|vsg-hw|vSGW|vSM|vspgwc|vspgwu|vtn-service|vtr|att-workflow-driver|tt-workflow-driver|ves-agent|voltha-bbsim|openolt|sadis-server|kafka-topic-exporter|pyvoltha|voltha-adtran-adapter|voltha-openolt-adapter|voltha-openonu-adapter|plyxproto|voltha-protos|alpine-grpc-base|cordctl|voltha-go|voltha-helm-charts)$'
+    version-tag-projects-regexp: '^(xos.*|helm-charts|automation-tools|cord-tester|chameleon|rcord|mcord|ecord|acordion|addressmanager|epc-service|exampleservice|fabric|fabric-crossconnect|globalxos|hippie-oss|hss_db|hypercache|internetemulator|kubernetes-service|monitoring|olt-service|onos-service|openstack|progran|sdn-controller|simpleexampleservice|templateservice|vEE|vEG|vBBU|venb|vHSS|vMME|vnaas|vPGWC|vPGWU|vrouter|vsg|vsg-hw|vSGW|vSM|vspgwc|vspgwu|vtn-service|vtr|att-workflow-driver|tt-workflow-driver|ves-agent|voltha-bbsim|openolt|sadis-server|kafka-topic-exporter|pyvoltha|voltha-adtran-adapter|voltha-openolt-adapter|voltha-openonu-adapter|plyxproto|voltha-protos|alpine-grpc-base|cordctl|voltha-go|voltha-helm-charts|voltha-onos|device-management)$'
 
     # PyPI related publishing variables
     #
diff --git a/jjb/pipeline/synopsys-check.groovy b/jjb/pipeline/synopsys-check.groovy
index b46e470..f111415 100644
--- a/jjb/pipeline/synopsys-check.groovy
+++ b/jjb/pipeline/synopsys-check.groovy
@@ -20,7 +20,7 @@
   }
 
   options {
-      timeout(30)
+      timeout(240)
   }
 
   stages {
@@ -34,25 +34,46 @@
     stage ("Get repo list") {
       steps {
         script {
+          writeFile file: 'get_repo_list.py', text: """
+#!/usr/bin/env python
+
+import json
+import os
+import requests
+
+if "github_organization" in os.environ:
+    # this is a github org
+    github_req = requests.get("https://api.github.com/orgs/%s/repos" %
+                              os.environ["github_organization"])
+
+    # pull out the "name" key out of each item
+    repo_list = map(lambda item: item["name"], github_req.json())
+
+else:
+    # this is a gerrit server
+
+    # fetch the list of projects
+    gerrit_req = requests.get("%s/projects/?pp=0" %
+                              os.environ["git_server_url"])
+    # remove XSSI prefix
+    # https://gerrit-review.googlesource.com/Documentation/rest-api.html#output
+    gerrit_json = json.loads(gerrit_req.text.splitlines()[1])
+
+    # remove repos which don't contain code
+    repo_list = [repo for repo in gerrit_json.keys()
+                 if repo not in ["All-Projects", "All-Users", "voltha-bal"]]
+
+# sort and print
+print(",".join(sorted(repo_list)))
+"""
+
           /* this defines the variable globally - not ideal, but works - see:
           https://stackoverflow.com/questions/50571316/strange-variable-scoping-behavior-in-jenkinsfile
           */
           repos = sh(
-              returnStdout: true,
-              script: """
-                #!/usr/bin/env bash
-                set -eu -o pipefail
+            returnStdout: true,
+            script: "python -u get_repo_list.py").trim().split(",")
 
-                if [ -z "${github_organization}" ]
-                then
-                  # no github org set, assume gerrit server
-                  curl "${git_server_url}/projects/?pp=0" | python -c 'import json,sys; ij=sys.stdin.readlines(); obj=json.loads(ij[1]); print(",".join(obj.keys()))'
-                else
-                  # github org set, assume github organization
-                  curl -sS "https://api.github.com/orgs/${github_organization}/repos" | python -c 'import json,sys;obj=json.load(sys.stdin); print ",".join(map(lambda item: item["name"], obj))'
-                fi
-                """
-              ).split(",")
           echo "repo list: ${repos}"
         }
       }
@@ -63,18 +84,17 @@
         script {
           repos.each { gitRepo ->
             sh "echo Checking out: ${gitRepo}"
-            checkout(
-                [
+            checkout(changelog: false, scm: [
                 $class: 'GitSCM',
                 userRemoteConfigs: [[
-                url: "${params.git_server_url}/${gitRepo}/",
-                name: "${branch}",
+                  url: "${params.git_server_url}/${gitRepo}/",
+                  name: "${branch}",
                 ]],
                 extensions: [
-                [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gitRepo}"],
-                [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+                  [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gitRepo}"],
+                  [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
                 ],
-                ])
+              ])
           }
         }
       }
diff --git a/jjb/pipeline/xos-service-upgrade.groovy b/jjb/pipeline/xos-service-upgrade.groovy
index 02edeeb..a362efc 100644
--- a/jjb/pipeline/xos-service-upgrade.groovy
+++ b/jjb/pipeline/xos-service-upgrade.groovy
@@ -15,6 +15,8 @@
 // chart-api-test-helm.groovy
 // Checks functionality of the helm-chart, without overriding the version/tag used
 
+def serviceName = "${gerritProject}"
+
 pipeline {
 
   /* no label, executor is determined by JJB */
@@ -110,6 +112,18 @@
     }
     stage('Verify') {
       steps {
+        script {
+          if (serviceName == "olt-service") {
+            serviceName = "volt"
+          }
+          else if (serviceName == "onos-service") {
+            serviceName = "onos"
+          }
+          else if (serviceName == "kubernetes-service") {
+            serviceName = "kubernetes"
+          }
+        }
+        echo "serviceName: ${serviceName}"
         sh """
            #!/usr/bin/env bash
            set -ex -o pipefail
@@ -117,7 +131,7 @@
 
            #wait for xos-core and models to be loaded
            timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
-           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
+           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${serviceName}\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
 
            ## get pod logs
            for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
@@ -171,7 +185,7 @@
            echo \$SERVICES
 
            cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
-           for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i create -d Log -T -v TESTLIBRARY:${gerritProject}_library.robot \$i\$testname"; sleep 2; done || true
+           for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i create -d Log -T -v TESTLIBRARY:${serviceName}_library.robot \$i\$testname"; sleep 2; done || true
 
            popd
            """
@@ -210,8 +224,8 @@
 
            #wait for xos-core and models to be loaded
            timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
-           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").state'| grep -q present; do echo 'Waiting for New Service to be loaded'; sleep 5; done"
-           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").version'| grep -q \$DOCKER_TAG; do echo 'Waiting for New Service Version Check'; sleep 5; done"
+           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${serviceName}\\").state'| grep -q present; do echo 'Waiting for New Service to be loaded'; sleep 5; done"
+           timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${serviceName}\\").version'| grep -q \$DOCKER_TAG; do echo 'Waiting for New Service Version Check'; sleep 5; done"
            sleep 120
            """
       }
@@ -227,7 +241,7 @@
            SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
            echo \$SERVICES
            cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
-           for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i get -d Log -T -v TESTLIBRARY:${gerritProject}_library.robot \$i\$testname"; sleep 2; done || true
+           for i in \$SERVICES; do bash -c "robot -v SETUP_FLAG:Setup -i get -d Log -T -v TESTLIBRARY:${serviceName}_library.robot \$i\$testname"; sleep 2; done || true
 
            ## get pod logs
            for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
diff --git a/jjb/verify/device-management.yaml b/jjb/verify/device-management.yaml
new file mode 100644
index 0000000..e611365
--- /dev/null
+++ b/jjb/verify/device-management.yaml
@@ -0,0 +1,27 @@
+---
+# verification jobs for 'device-management' repo
+
+- project:
+    name: device-management
+    project: '{name}'
+
+    jobs:
+      - 'verify-device-management-jobs':
+          branch-regexp: '{supported-branches-regexp}'
+      - 'publish-device-management-jobs':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'verify-device-management-jobs'
+    jobs:
+      - 'verify-licensed'
+      - 'tag-collision-reject':
+          dependency-jobs: 'verify_device-management_licensed'
+      - 'make-unit-test'
+
+- job-group:
+    name: 'publish-device-management-jobs'
+    jobs:
+      - 'docker-publish':
+          docker-repo: 'opencord'
+          dependency-jobs: 'version-tag'
diff --git a/jjb/verify/voltha-onos.yaml b/jjb/verify/voltha-onos.yaml
new file mode 100644
index 0000000..676bc97
--- /dev/null
+++ b/jjb/verify/voltha-onos.yaml
@@ -0,0 +1,29 @@
+---
+# verification jobs for 'voltha-onos' repo
+
+- project:
+    name: voltha-onos
+    project: '{name}'
+
+    jobs:
+      - 'verify-voltha-onos-jobs':
+          branch-regexp: '{supported-branches-regexp}'
+      - 'publish-voltha-onos-jobs':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'verify-voltha-onos-jobs'
+    jobs:
+      - 'verify-licensed'
+      - 'tag-collision-reject':
+          dependency-jobs: 'verify_voltha-onos_licensed'
+      - 'make-unit-test':
+          unit-test-targets: 'build'
+          junit-allow-empty-results: true
+
+- job-group:
+    name: 'publish-voltha-onos-jobs'
+    jobs:
+      - 'docker-publish':
+          docker-repo: 'voltha'
+          dependency-jobs: 'version-tag'