Merge "fixing bugs in all api test pipeline script for helm deployment"
diff --git a/jjb/build_openolt_deb.yaml b/jjb/build_openolt_deb.yaml
new file mode 100644
index 0000000..1a69c4e
--- /dev/null
+++ b/jjb/build_openolt_deb.yaml
@@ -0,0 +1,49 @@
+---
+# build_openolt_deb
+
+- project:
+    name: build_openolt_deb
+
+    project-name: '{name}'
+
+    jobs:
+      - 'build_openolt_deb'
+
+- job-template:
+    id: build_openolt_deb
+    name: 'build_openolt_deb'
+    description: |
+      <!-- Managed by Jenkins Job Builder -->
+      Created by {id} job-template from ci-management/jjb/olt-voltha.yaml
+
+    triggers:
+      - cord-infra-gerrit-trigger-merge:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '^(openolt)$'
+          branch-regexp: '{modern-branches-regexp}'
+          file-include-regexp: '{doc-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    parameters:
+      - string:
+         name: notificationEmail
+         default: 'shad@opennetworking.org'
+         description: ''
+
+    node: 'openolt_deb_onf_agent'
+
+    project-type: pipeline
+    concurrent: true
+
+    pipeline-scm:
+      script-path: 'Jenkinsfile'
+      scm:
+        - git:
+           url: '{gerrit-server-url}/openolt'
+           branches:
+             - 'master'
diff --git a/jjb/helm.yaml b/jjb/charts.yaml
similarity index 95%
rename from jjb/helm.yaml
rename to jjb/charts.yaml
index dbb08e3..ce2fd37 100644
--- a/jjb/helm.yaml
+++ b/jjb/charts.yaml
@@ -57,8 +57,8 @@
 # publish over ssh: https://docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.ssh
     publishers:
       - ssh:
-          site: 'CORD Wiki'
+          site: '{docs-ssh-host}'
           source: 'chart_repo/**'
           remove-prefix: 'chart_repo'
-          target: '//var/www/guide/charts/$GERRIT_BRANCH'
+          target: '//var/www/charts/$GERRIT_BRANCH'
 
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index e7d2896..bebda2a 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -41,9 +41,12 @@
     # regexp for gerrit triggers
     # list of supported branches, for branch-regexp
     supported-branches-regexp: '^(master|cord-6.0|cord-5.0|cord-4.1|cord-4.0)$'
+    legacy-branches-regexp: '^(cord-5.0|cord-4.1|cord-4.0)$'
     modern-branches-regexp: '^(master|cord-6.0)$'
 
     # for matching files with file-include-regexp
     all-files-regexp: '.*'
-    doc-files-regexp: "^docs/.*"
+    doc-files-regexp: '^docs/.*'
 
+    # Jenkins SSH host doc publisher
+    docs-ssh-host: 'guide.opencord.org'
diff --git a/jjb/docs-legacy.yaml b/jjb/docs-legacy.yaml
new file mode 100644
index 0000000..69dcafa
--- /dev/null
+++ b/jjb/docs-legacy.yaml
@@ -0,0 +1,110 @@
+---
+# Legacy CORD documentation verification and publish tasks
+
+- project:
+    name: verify-docs-legacy
+
+    jobs:
+      - 'verify-documentation-legacy':
+          project-regexp: '^(cord|platform-install|cord-tester|rcord|ecord|mcord|opencloud|xos|xos-gui|xos-tosca)$'
+          branch-regexp: '{legacy-branches-regexp}'
+
+- project:
+    name: publish-docs-legacy
+
+    jobs:
+      - 'publish-documentation-legacy':
+          project-regexp: '^(cord|platform-install|cord-tester|rcord|ecord|mcord|opencloud|xos|xos-gui|xos-tosca)$'
+          branch-regexp: '{legacy-branches-regexp}'
+
+- job-template:
+    id: verify-documentation-legacy
+    name: "verify-documentation-legacy"
+
+    triggers:
+      - cord-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project-regexp}'
+          branch-regexp: '{branch-regexp}'
+          file-include-regexp: '{doc-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    scm:
+      - cord-infra-gerrit-repo-scm:
+          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
+          branch: '$GERRIT_BRANCH'
+          destination-dir: 'cord'
+
+    node: '{build-node}'
+    project-type: freestyle
+    concurrent: false
+
+    builders:
+      - cord-infra-gerrit-repo-patch:
+          destination-dir: 'cord'
+          project: '$GERRIT_PROJECT'
+          change-number: '$GERRIT_CHANGE_NUMBER'
+          patchset-number: '$GERRIT_PATCHSET_NUMBER'
+      - shell: |
+          cd cord/build/docs
+          make test
+
+- job-template:
+    id: publish-documentation-legacy
+    name: 'publish-documentation-legacy'
+
+    triggers:
+      - cord-infra-gerrit-trigger-merge:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project-regexp}'
+          branch-regexp: '{branch-regexp}'
+          file-include-regexp: '{doc-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    scm:
+      - cord-infra-gerrit-repo-scm:
+          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
+          branch: '$GERRIT_BRANCH'
+          destination-dir: 'cord'
+
+    node: '{build-node}'
+    project-type: freestyle
+    concurrent: false
+
+    builders:
+      - shell: |
+          cd cord/build/docs
+          make build
+
+# publish over ssh: https://docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.ssh
+    publishers:
+      - ssh:
+          site: '{docs-ssh-host}'
+          source: 'cord/build/docs/_book/**'
+          remove-prefix: 'cord/build/docs/_book'
+          target: '//var/www/guide/$GERRIT_BRANCH'
+      - ssh:
+          site: '{docs-ssh-host}'
+          source: 'cord/build/docs/xos/swagger/**'
+          remove-prefix: 'cord/build/docs/xos'
+          target: '//var/www/guide/$GERRIT_BRANCH'
diff --git a/jjb/docs.yaml b/jjb/docs.yaml
index 17ae369..e59fa44 100644
--- a/jjb/docs.yaml
+++ b/jjb/docs.yaml
@@ -2,21 +2,11 @@
 # CORD documentation verification and publish tasks
 
 - project:
-    name: verify-docs-legacy
-
-    # add repos that have documentation to the project list in both jobs
-    jobs:
-      - 'verify-documentation-legacy':
-          project-regexp: '^(cord|platform-install|cord-tester|rcord|ecord|mcord|opencloud|xos|xos-gui|xos-tosca)$'
-          branch-regexp: '{supported-branches-regexp}'
-
-- project:
     name: verify-docs
 
-    # add repos that have documentation to the project list in both jobs
     jobs:
       - 'verify-documentation':
-          other-docs-repos-regexp: '^(cord-tester|xos|xos-gui|xos-tosca)$'
+          other-docs-repos-regexp: '.*'
           branch-regexp: '{modern-branches-regexp}'
 
 - project:
@@ -24,51 +14,8 @@
 
     jobs:
       - 'publish-documentation':
-          project-regexp: '^(cord|platform-install|cord-tester|rcord|ecord|mcord|opencloud|xos|xos-gui|xos-tosca)$'
-          branch-regexp: '{supported-branches-regexp}'
-
-# Documentation job templates
-- job-template:
-    id: verify-documentation-legacy
-    name: "verify-documentation-legacy"
-
-    triggers:
-      - cord-infra-gerrit-trigger-patchset:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: '{project-regexp}'
-          branch-regexp: '{branch-regexp}'
-          file-include-regexp: '{doc-files-regexp}'
-          dependency-jobs: '{dependency-jobs}'
-
-    properties:
-      - cord-infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-          artifact-num-to-keep: '{artifact-num-to-keep}'
-
-    wrappers:
-      - lf-infra-wrappers:
-          build-timeout: '{build-timeout}'
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
-    scm:
-      - cord-infra-gerrit-repo-scm:
-          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
-          branch: '$GERRIT_BRANCH'
-          destination-dir: 'cord'
-
-    node: '{build-node}'
-    project-type: freestyle
-    concurrent: false
-
-    builders:
-      - cord-infra-gerrit-repo-patch:
-          destination-dir: 'cord'
-          project: '$GERRIT_PROJECT'
-          change-number: '$GERRIT_CHANGE_NUMBER'
-          patchset-number: '$GERRIT_PATCHSET_NUMBER'
-      - shell: |
-          cd cord/build/docs
-          make test
+          other-docs-repos-regexp: '.*'
+          branch-regexp: '{modern-branches-regexp}'
 
 - job-template:
     id: verify-documentation
@@ -140,12 +87,29 @@
     name: 'publish-documentation'
 
     triggers:
-      - cord-infra-gerrit-trigger-merge:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: '{project-regexp}'
-          branch-regexp: '{branch-regexp}'
-          file-include-regexp: '{doc-files-regexp}'
+      - gerrit:
+          server-name: '{gerrit-server-name}'
           dependency-jobs: '{dependency-jobs}'
+          silent-start: true
+          trigger-on:
+            - change-merged-event
+          projects:
+            - project-compare-type: PLAIN
+              project-pattern: 'docs'
+              branches:
+                - branch-compare-type: REG_EXP
+                  branch-pattern: '{branch-regexp}'
+              file-paths:
+                - compare-type: REG_EXP
+                  pattern: '{all-files-regexp}'
+            - project-compare-type: REG_EXP
+              project-pattern: '{other-docs-repos-regexp}'
+              branches:
+                - branch-compare-type: REG_EXP
+                  branch-pattern: '{branch-regexp}'
+              file-paths:
+                - compare-type: REG_EXP
+                  pattern: '{doc-files-regexp}'
 
     properties:
       - cord-infra-properties:
@@ -169,19 +133,18 @@
 
     builders:
       - shell: |
-          cd cord/build/docs
+          cd cord/docs
           make build
 
 # publish over ssh: https://docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.ssh
     publishers:
       - ssh:
-          site: 'CORD Wiki'
-          source: 'cord/build/docs/_book/**'
-          remove-prefix: 'cord/build/docs/_book'
+          site: '{docs-ssh-host}'
+          source: 'cord/docs/_book/**'
+          remove-prefix: 'cord/docs/_book'
           target: '//var/www/guide/$GERRIT_BRANCH'
       - ssh:
-          site: 'CORD Wiki'
-          source: 'cord/build/docs/xos/swagger/**'
-          remove-prefix: 'cord/build/docs/xos'
+          site: '{docs-ssh-host}'
+          source: 'cord/docs/xos/swagger/**'
+          remove-prefix: 'cord/docs/xos'
           target: '//var/www/guide/$GERRIT_BRANCH'
-
diff --git a/jjb/imagebuilder.yaml b/jjb/imagebuilder.yaml
new file mode 100644
index 0000000..968a702
--- /dev/null
+++ b/jjb/imagebuilder.yaml
@@ -0,0 +1,69 @@
+---
+# CORD helm chart publishing tasks
+
+- project:
+    name: imagebuilder
+
+    # add repos that have documentation to the project list in both jobs
+    jobs:
+      - 'publish-imagebuilder':
+          project-regexp: '.*'
+          branch-regexp: '{supported-branches-regexp}'
+
+
+- job-template:
+    id: publish-imagebuilder
+    name: 'publish-imagebuilder'
+    description: |
+      Created by {id} job-template from ci-management/jjb/helm.yaml
+
+    triggers:
+      - cord-infra-gerrit-trigger-merge:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project-regexp}'
+          branch-regexp: '{branch-regexp}'
+          file-include-regexp: '{all-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    parameters:
+      - string:
+          name: executorNode
+          default: 'imagebuilder'
+          description: 'Name of the Jenkins node to run the job on'
+
+      - string:
+          name: manifestUrl
+          default: '{gerrit-server-url}/{cord-repo-manifest}'
+          description: 'URL to the repo manifest'
+
+      - string:
+          name: manifestBranch
+          default: '$GERRIT_BRANCH'
+          description: 'Name of the repo branch to use'
+
+      - bool:
+          name: build
+          default: false
+          description: 'Rebuild all containers (same as "docker build --no-cache")'
+
+      - bool:
+          name: force
+          default: false
+          description: 'Force remove obsolete tags/images (same as "docker rmi --force")'
+
+
+    project-type: pipeline
+    concurrent: false
+
+    dsl: !include-raw-escape: pipeline/imagebuilder.groovy
+
diff --git a/jjb/olt-voltha.yaml b/jjb/olt-voltha.yaml
deleted file mode 100644
index 70b6b19..0000000
--- a/jjb/olt-voltha.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
----
-# olt-voltha-build
-
-- project:
-    name: olt-voltha
-
-    project-name: '{name}'
-
-    jobs:
-      - 'olt-voltha-build'
-
-- job-template:
-    id: olt-voltha-build
-    name: 'olt_voltha_automated_build'
-    description: |
-      <!-- Managed by Jenkins Job Builder -->
-      Created by {id} job-template from ci-management/jjb/olt-voltha.yaml
-
-    properties:
-      - cord-infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-          artifact-num-to-keep: '{artifact-num-to-keep}'
-
-    parameters:
-      - string:
-         name: notificationEmail
-         default: 'luca@opennetworking.org, shad@opennetworking.org'
-         description: ''
-
-    node: 'olt-agent-onf'
-
-    project-type: pipeline
-    concurrent: true
-
-    pipeline-scm:
-      script-path: 'Jenkinsfile'
-      scm:
-        - git:
-           url: '{gerrit-server-url}/openolt'
-           branches:
-             - 'master'
diff --git a/jjb/onos-app-release.yaml b/jjb/onos-app-release.yaml
new file mode 100644
index 0000000..5790821
--- /dev/null
+++ b/jjb/onos-app-release.yaml
@@ -0,0 +1,63 @@
+---
+# onos-app-release
+
+- project:
+    name: onos-app-release
+
+    project-name: '{name}'
+
+    jobs:
+      - 'onos-app-release'
+
+
+- job-template:
+    id: onos-app-release
+    name: 'onos-app-release'
+    description: |
+      <!-- Managed by Jenkins Job Builder -->
+      Created by {id} job-template from ci-management/jjb/onos-app-release.yaml
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - ssh-agent-credentials:
+          users:
+              - 'gerrit-jenkins-user'
+      - build-user-vars
+
+    parameters:
+      - string:
+         name: app
+         default: ''
+         description: 'Name of the app repository on the OpenCORD Gerrit server.\n e.g. vtn'
+
+      - string:
+         name: version
+         default: ''
+         description: 'Version to release.\n e.g. 1.0.0'
+
+      - string:
+         name: nextVersion
+         default: ''
+         description: 'Snapshot version to move the code forward to.\n e.g. 1.1.0'
+
+      - string:
+         name: branch
+         default: 'master'
+         description: 'Name of the branch to release on.'
+
+    node: 'ubuntu16.04-basebuild-1c-2g'
+    project-type: pipeline
+    concurrent: true
+
+    pipeline-scm:
+      script-path: 'Jenkinsfile.release'
+      scm:
+        - git:
+            url: '{gerrit-server-url}/cord-onos-publisher'
+            branches:
+              - 'master'
+
diff --git a/jjb/pipeline/helm-api-test.groovy b/jjb/pipeline/helm-api-test.groovy
index 8a6e160..4540502 100644
--- a/jjb/pipeline/helm-api-test.groovy
+++ b/jjb/pipeline/helm-api-test.groovy
@@ -44,8 +44,8 @@
         stage('images') {
           steps {
             sh '''
-               pushd cord/automation-tools
-               ./developer/imagebuilder.py -f ../helm-charts/examples/api-test-images.yaml
+               pushd cord/automation-tools/developer
+               ./imagebuilder.py -f ../../helm-charts/examples/api-test-images.yaml
                popd
                '''
           }
diff --git a/jjb/pipeline/imagebuilder.groovy b/jjb/pipeline/imagebuilder.groovy
new file mode 100644
index 0000000..deee937
--- /dev/null
+++ b/jjb/pipeline/imagebuilder.groovy
@@ -0,0 +1,79 @@
+/* imagebuilder pipeline */
+pipeline {
+
+  /* no label, executor is determined by JJB */
+  agent {
+    label "${params.executorNode}"
+  }
+  stages {
+
+    stage('repo') {
+      steps {
+        checkout(changelog: false, \
+          poll: false,
+          scm: [$class: 'RepoScm', \
+            manifestRepositoryUrl: "${params.manifestUrl}", \
+            manifestBranch: "${params.manifestBranch}", \
+            currentBranch: true, \
+            destinationDir: 'cord', \
+            forceSync: true,
+            resetFirst: true, \
+            quiet: true, \
+            jobs: 4, \
+            showAllChanges: true] \
+          )
+      }
+    }
+
+    stage('imagebuilder'){
+      steps {
+        sh """
+           #!/usr/bin/env bash
+
+           mkdir "$WORKSPACE/ib_logs"
+           ib_args=""
+
+           if [ "${params.force}" = "true" ]; then
+             ib_args+="--force "
+           fi
+
+           if [ "${params.build}" = "true" ]; then
+             ib_args+="--build "
+           fi
+
+           pushd cord/automation-tools/developer
+           ./imagebuilder.py -vv \${ib_args} -c docker_images.yml \
+                             -a "$WORKSPACE/ib_actions.yml" \
+                             -l "$WORKSPACE/ib_logs" \
+                             -g "$WORKSPACE/ib_graph.dot"
+           popd
+           """
+      }
+    }
+
+    stage('push'){
+       steps {
+         script {
+          def ib_actions = readYaml( file:"$WORKSPACE/ib_actions.yml" )
+
+          withDockerRegistry([credentialsId: 'docker-artifact-push-credentials']) {
+            for(image in ib_actions.ib_built){
+              for(tag in image.tags){
+                push_tag = image.base + ":" + tag
+                echo "Pushing image: " + push_tag
+                docker.image(push_tag).push()
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
+  post {
+    always {
+      archiveArtifacts artifacts: 'ib_actions.yml, ib_graph.dot, ib_logs/*', fingerprint: true
+      deleteDir()
+    }
+  }
+}
diff --git a/jjb/xos-unit.yaml b/jjb/xos-unit.yaml
index 74aa652..3ac10ed 100644
--- a/jjb/xos-unit.yaml
+++ b/jjb/xos-unit.yaml
@@ -64,11 +64,14 @@
           pip install ipaddress==1.0.19
           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"
 
           # Run the tests
-          cd $BASEDIR
+          if [ $GERRIT_PROJECT = 'xos' ] ; then
+            cd $BASEDIR
+          else
+            cd $BASEDIR/cord/orchestration/xos_services/$GERRIT_PROJECT/xos
+          fi
           nose2 --verbose  --exclude-ignored-files