Merge "Test with new jenkins file"
diff --git a/jjb/aaa.yaml b/jjb/aaa.yaml
deleted file mode 100644
index 398b4ff..0000000
--- a/jjb/aaa.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
----
-# maven job for 'aaa' repo
-
-- project:
-    name: aaa
-    project: '{name}'
-
-    jobs:
-      - 'aaa':
-          branch-regexp: '{supported-branches-regexp}'
-
-- job-group:
-    name: 'aaa'
-    jobs:
-      - 'aaa-gerrit':
-            goals: 'clean install'
-      - 'verify-licensed'
-
-- job-template:
-    name: 'aaa-gerrit'
-    builders:
-        - lf-maven-build:
-           mvn-goals: '{goals}'
-        - 'cord-infra-sonarqube':
-           project: '{name}'
-
-    triggers:
-      - cord-infra-gerrit-trigger-patchset:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: 'aaa'
-          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}'
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index 5ca5ae9..e7d2896 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -40,8 +40,10 @@
 
     # regexp for gerrit triggers
     # list of supported branches, for branch-regexp
-    supported-branches-regexp: '^(master|cord-5.0|cord-4.1|cord-4.0)$'
+    supported-branches-regexp: '^(master|cord-6.0|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/.*"
+
diff --git a/jjb/helm-api-test.yaml b/jjb/helm-api-test.yaml
new file mode 100644
index 0000000..a9ec6a8
--- /dev/null
+++ b/jjb/helm-api-test.yaml
@@ -0,0 +1,48 @@
+---
+# CORD API tests using helm
+
+- job-template:
+    id: helm-api-test
+    name: 'verify_{project}_helm-api-test'
+    description: |
+      Created by helm-api-test job-template from ci-management/jjb/helm-api-test.yaml
+
+    triggers:
+      - cord-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '^{project}$'
+          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: '60'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    parameters:
+      - string:
+         name: executorNode
+         default: 'ubuntu16.04-basebuild-4c-8g'
+         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'
+
+    project-type: pipeline
+    concurrent: true
+
+    dsl: !include-raw-escape: pipeline/helm-api-test.groovy
+
diff --git a/jjb/helm.yaml b/jjb/helm.yaml
new file mode 100644
index 0000000..dbb08e3
--- /dev/null
+++ b/jjb/helm.yaml
@@ -0,0 +1,64 @@
+---
+# CORD helm chart publishing tasks
+
+- project:
+    name: helm-repo
+
+    # add repos that have documentation to the project list in both jobs
+    jobs:
+      - 'publish-helm-repo':
+          project-regexp: '^(helm-charts)$'
+          branch-regexp: '{supported-branches-regexp}'
+
+
+- job-template:
+    id: publish-helm-repo
+    name: 'publish-helm-repo'
+    description: |
+      Created by publish-helm-repo 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}'
+
+    scm:
+      - lf-infra-gerrit-scm:
+          git-url: '$GIT_URL/$GERRIT_PROJECT'
+          refspec: ''
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: 'false'
+          choosing-strategy: default
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    node: '{build-node}'
+    project-type: freestyle
+    concurrent: false
+
+    builders:
+      - shell: |
+          helm init --client-only
+          helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
+          ./scripts/helmrepo.sh
+
+# publish over ssh: https://docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.ssh
+    publishers:
+      - ssh:
+          site: 'CORD Wiki'
+          source: 'chart_repo/**'
+          remove-prefix: 'chart_repo'
+          target: '//var/www/guide/charts/$GERRIT_BRANCH'
+
diff --git a/jjb/maven.yaml b/jjb/maven.yaml
new file mode 100644
index 0000000..02195e3
--- /dev/null
+++ b/jjb/maven.yaml
@@ -0,0 +1,48 @@
+---
+# maven install jobs for cord onos app repos
+
+- job-template:
+    id: maven-install
+    name: '{project}-gerrit'
+    description: |
+      <!-- Managed by Jenkins Job Builder -->
+      Created by {id} job-template from ci-management/jjb/maven.yaml
+
+    node: 'ubuntu16.04-basebuild-1c-2g'
+    project-type: maven
+    maven:
+      root-pom: pom.xml
+      goals: 'clean install'
+
+    parameters:
+      - string:
+         name: GERRIT_BRANCH
+         default: 'master'
+         description: 'Use default when using "Build Now"'
+
+      - string:
+         name: GERRIT_REFSPEC
+         default: 'refs/heads/master'
+         description: 'Use default when using "Build Now"'
+
+    triggers:
+      - cord-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '{project}'
+          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}'
+
+    scm:
+      - git:
+          url: '{gerrit-server-url}/{project}'
+          branches:
+            - '$GERRIT_BRANCH'
+          refspec: '$GERRIT_REFSPEC'
+          choosing-strategy: 'gerrit'
+          shallow-clone: true
diff --git a/jjb/maven/aaa.yaml b/jjb/maven/aaa.yaml
new file mode 100644
index 0000000..9a86551
--- /dev/null
+++ b/jjb/maven/aaa.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'aaa' repo
+
+- project:
+    name: aaa
+    project: '{name}'
+
+    jobs:
+      - 'aaa-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'aaa-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/config.yaml b/jjb/maven/config.yaml
new file mode 100644
index 0000000..d865397
--- /dev/null
+++ b/jjb/maven/config.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'config' repo
+
+- project:
+    name: config
+    project: '{name}'
+
+    jobs:
+      - 'config-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'config-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/dhcpl2relay.yaml b/jjb/maven/dhcpl2relay.yaml
new file mode 100644
index 0000000..93c3648
--- /dev/null
+++ b/jjb/maven/dhcpl2relay.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'dhcpl2relay' repo
+
+- project:
+    name: dhcpl2relay
+    project: '{name}'
+
+    jobs:
+      - 'dhcpl2relay-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'dhcpl2relay-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/igmp.yaml b/jjb/maven/igmp.yaml
new file mode 100644
index 0000000..438e78b
--- /dev/null
+++ b/jjb/maven/igmp.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'igmp' repo
+
+- project:
+    name: igmp
+    project: '{name}'
+
+    jobs:
+      - 'igmp-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'igmp-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/igmpproxy.yaml b/jjb/maven/igmpproxy.yaml
new file mode 100644
index 0000000..855c809
--- /dev/null
+++ b/jjb/maven/igmpproxy.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'igmpproxy' repo
+
+- project:
+    name: igmpproxy
+    project: '{name}'
+
+    jobs:
+      - 'igmpproxy-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'igmpproxy-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/mcast.yaml b/jjb/maven/mcast.yaml
new file mode 100644
index 0000000..4ed1433
--- /dev/null
+++ b/jjb/maven/mcast.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'mcast' repo
+
+- project:
+    name: mcast
+    project: '{name}'
+
+    jobs:
+      - 'mcast-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'mcast-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/olt.yaml b/jjb/maven/olt.yaml
new file mode 100644
index 0000000..a84c9bc
--- /dev/null
+++ b/jjb/maven/olt.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'olt' repo
+
+- project:
+    name: olt
+    project: '{name}'
+
+    jobs:
+      - 'olt-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'olt-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/sadis.yaml b/jjb/maven/sadis.yaml
new file mode 100644
index 0000000..9b4dff4
--- /dev/null
+++ b/jjb/maven/sadis.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'sadis' repo
+
+- project:
+    name: sadis
+    project: '{name}'
+
+    jobs:
+      - 'sadis-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'sadis-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/maven/vtn.yaml b/jjb/maven/vtn.yaml
new file mode 100644
index 0000000..3efdd96
--- /dev/null
+++ b/jjb/maven/vtn.yaml
@@ -0,0 +1,16 @@
+---
+# maven job for 'vtn' repo
+
+- project:
+    name: vtn-onos
+    project: '{name}'
+
+    jobs:
+      - 'vtn-gerrit':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'vtn-gerrit'
+    jobs:
+      - 'verify-licensed'
+      - 'maven-install'
diff --git a/jjb/pipeline/helm-api-test.groovy b/jjb/pipeline/helm-api-test.groovy
new file mode 100644
index 0000000..c776510
--- /dev/null
+++ b/jjb/pipeline/helm-api-test.groovy
@@ -0,0 +1,113 @@
+/* helm-api-test pipeline */
+
+pipeline {
+
+  parameters {
+    string(name:'executorNode', defaultValue:'invalid', description:'Name of the Jenkins node to run the job on')
+    string(name:'manifestUrl', defaultValue:'invalid', description:'URL to the repo manifest')
+    string(name:'manifestBranch', defaultValue:'master', description:'Name of the repo branch to use')
+  }
+
+  /* no label, executor is determined by JJB */
+  agent {
+    label '${params.executorNode}'
+  }
+
+  stages {
+
+    stage('checkout') {
+      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('prep') {
+      parallel {
+
+        stage('images') {
+          steps {
+            sh 'cd cord/build; ./scripts/imagebuilder.py -f helm-charts/examples/test-images.yaml'
+
+          }
+        }
+
+        stage('minikube') {
+          steps {
+            /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
+            sh '''
+               export MINIKUBE_WANTUPDATENOTIFICATION=false;
+               export MINIKUBE_WANTREPORTERRORPROMPT=false;
+               export CHANGE_MINIKUBE_NONE_USER=true;
+               export MINIKUBE_HOME=$HOME;
+               mkdir -p $HOME/.kube || true;
+               touch $HOME/.kube/config;
+               export KUBECONFIG=$HOME/.kube/config;
+               minikube start --vm-driver=none;
+
+               chown -R $USER $HOME/.minikube;
+               chgrp -R $(id -g) $HOME/.minikube;
+
+               for i in {1..150}; do # timeout for 5 minutes
+                   ./kubectl get po &> /dev/null
+                   if [ $? -ne 1 ]; then
+                      break
+                  fi
+                  sleep 2
+               done
+               '''
+          }
+        }
+      }
+    }
+
+    stage('helm') {
+      steps {
+        sh 'helm init && sleep 60'
+      }
+    }
+
+    stage('xos') {
+      steps {
+        sh '''
+           cd cord/build/helm-charts;
+           helm dep up xos-core;
+           helm install -f examples/test-values.yaml -f examples/candidate-tag-values.yaml xos-core -n xos-core;
+           sleep 60
+           '''
+      }
+    }
+
+    stage('test'){
+      steps {
+        sh 'helm test xos-core'
+        sh 'kubectl logs xos-core-api-test'
+      }
+      post {
+        always {
+          archive '/tmp/helm_test_xos_core_logs_*/**'
+
+        }
+      }
+    }
+  }
+
+  post {
+    always {
+      sh 'kubectl delete pod xos-core-api-test'
+      sh 'helm delete --purge xos-core'
+      deleteDir()
+    }
+  }
+}
diff --git a/jjb/sonar.yaml b/jjb/sonar.yaml
index 8173268..344a1c2 100644
--- a/jjb/sonar.yaml
+++ b/jjb/sonar.yaml
@@ -57,10 +57,10 @@
     scm:
       - lf-infra-gerrit-scm:
           git-url: '$GIT_URL/$GERRIT_PROJECT'
-          refspec: '$GERRIT_REFSPEC'
+          refspec: ''
           branch: '$GERRIT_BRANCH'
           submodule-recursive: 'false'
-          choosing-strategy: gerrit
+          choosing-strategy: default
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
 
     node: 'ubuntu16.04-basebuild-1c-2g'
diff --git a/jjb/verify/exampleservice.yaml b/jjb/verify/exampleservice.yaml
new file mode 100644
index 0000000..5f42c26
--- /dev/null
+++ b/jjb/verify/exampleservice.yaml
@@ -0,0 +1,19 @@
+---
+# verification jobs for 'exampleservice' repo
+
+- project:
+    name: exampleservice
+    project: '{name}'
+
+    jobs:
+      - 'verify-exampleservice-jobs':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'verify-exampleservice-jobs'
+    jobs:
+      - 'verify-licensed'
+      - 'verify-sonarqube':
+          dependency-jobs: 'verify_exampleservice_licensed'
+      - 'api-test':
+          dependency-jobs: 'verify_exampleservice_sonarqube'
diff --git a/jjb/verify/helm-charts.yaml b/jjb/verify/helm-charts.yaml
index 621168b..90930a8 100644
--- a/jjb/verify/helm-charts.yaml
+++ b/jjb/verify/helm-charts.yaml
@@ -7,7 +7,7 @@
 
     jobs:
       - 'verify-helm-charts-jobs':
-          branch-regexp: '^master$'
+          branch-regexp: '{modern-branches-regexp}'
 
 - job-group:
     name: 'verify-helm-charts-jobs'
@@ -17,4 +17,6 @@
           dependency-jobs: 'verify_helm-charts_licensed'
       - 'verify-helm-lint':
           dependency-jobs: 'verify_helm-charts_sonarqube'
+      - 'helm-api-test':
+          dependency-jobs: 'verify_helm-charts_helm-lint'
 
diff --git a/jjb/verify/simpleexampleservice.yaml b/jjb/verify/simpleexampleservice.yaml
new file mode 100644
index 0000000..397c324
--- /dev/null
+++ b/jjb/verify/simpleexampleservice.yaml
@@ -0,0 +1,19 @@
+---
+# verification jobs for 'simpleexampleservice' repo
+
+- project:
+    name: simpleexampleservice
+    project: '{name}'
+
+    jobs:
+      - 'verify-simpleexampleservice-jobs':
+          branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+    name: 'verify-simpleexampleservice-jobs'
+    jobs:
+      - 'verify-licensed'
+      - 'verify-sonarqube':
+          dependency-jobs: 'verify_simpleexampleservice_licensed'
+      - 'api-test':
+          dependency-jobs: 'verify_simpleexampleservice_sonarqube'
diff --git a/packer/provision/basebuild.sh b/packer/provision/basebuild.sh
index 2015ef3..b1ff0d4 100644
--- a/packer/provision/basebuild.sh
+++ b/packer/provision/basebuild.sh
@@ -143,6 +143,15 @@
     rm -rf helm.tgz ${HELM_PLATFORM}
     popd
 
+    # install kubectl
+    KUBECTL_VERSION="1.9.5"
+    KUBECTL_SHA256SUM="9c67b6e80e9dd3880511c7d912c5a01399c1d74aaf4d71989c7d5a4f2534bcd5"
+    curl -L -o /tmp/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
+    echo "$KUBECTL_SHA256SUM  /tmp/kubectl" | sha256sum -c -
+    mv /tmp/kubectl /usr/local/bin/kubectl
+    chmod a+x /usr/local/bin/kubectl
+    rm -f /tmp/kubectl
+
     # install minikube
     MINIKUBE_VERSION="0.26.1"
     MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')"