[VOL-3358] Initial template for voltha-scale-matrix job

Change-Id: If3eb064b4d8eef5bb1cf6ba7d815a8b8a6f9d34b
diff --git a/jjb/pipeline/voltha-scale-matrix.groovy b/jjb/pipeline/voltha-scale-matrix.groovy
new file mode 100644
index 0000000..5aa4b3e
--- /dev/null
+++ b/jjb/pipeline/voltha-scale-matrix.groovy
@@ -0,0 +1,122 @@
+// Copyright 2019-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.
+
+pipeline {
+
+  agent {
+    label "${params.buildNode}"
+  }
+  options {
+      timeout(time: 30, unit: 'MINUTES')
+  }
+  environment {
+
+  }
+
+  stages {
+    stage ('Cleanup') {
+      steps {
+        timeout(time: 11, unit: 'MINUTES') {
+          sh returnStdout: false, script: """
+            helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com
+            helm repo add stable https://kubernetes-charts.storage.googleapis.com
+            helm repo add onf https://charts.opencord.org
+            helm repo add cord https://charts.opencord.org
+            helm repo add onos https://charts.onosproject.org
+            helm repo add atomix https://charts.atomix.io
+            helm repo add bbsim-sadis https://ciena.github.io/bbsim-sadis-server/charts
+            helm repo update
+
+            # removing ETCD port forward
+            P_ID="\$(ps e -ww -A | grep "_TAG=etcd-port-forward" | grep -v grep | awk '{print \$1}')"
+            if [ -n "\$P_ID" ]; then
+              kill -9 \$P_ID
+            fi
+
+            for hchart in \$(helm list -q | grep -E -v 'docker-registry|kafkacat');
+            do
+                echo "Purging chart: \${hchart}"
+                helm delete "\${hchart}"
+            done
+            bash /home/cord/voltha-scale/wait_for_pods.sh
+
+            test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down
+
+            cd $WORKSPACE
+            rm -rf $WORKSPACE/*
+          """
+        }
+      }
+    }
+    stage('Clone kind-voltha') {
+      steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[ url: "https://gerrit.opencord.org/kind-voltha", ]],
+          branches: [[ name: "master", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
+        script {
+          sh(script:"""
+          if [ '${kindVolthaChange}' != '' ] ; then
+          cd $WORKSPACE/kind-voltha;
+          git fetch https://gerrit.opencord.org/kind-voltha ${volthaSystemTestsChange} && git checkout FETCH_HEAD
+          fi
+          """)
+        }
+      }
+    }
+    stage('Clone voltha-system-tests') {
+      steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[ url: "https://gerrit.opencord.org/voltha-system-tests", ]],
+          branches: [[ name: "${release}", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
+        script {
+          sh(script:"""
+            if [ '${volthaSystemTestsChange}' != '' ] ; then
+              cd $WORKSPACE/voltha-system-tests;
+              git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
+            fi
+            """)
+        }
+      }
+    }
+    stage('Deploy and test') {
+      repeat_deploy_and_test(topologies)
+    }
+  }
+}
+
+topologies = [
+  {'onu': 1, 'pon': 1},
+  {'onu': 2, 'pon': 1},
+  {'onu': 2, 'pon': 2},
+]
+
+def repeat_deploy_and_test(list) {
+    for (int i = 0; i < list.size(); i++) {
+        sh "echo Setting up with ${list[i]['pon']}x${list[i]['onu']}"
+    }
+}