[VOL-3780] Adding support to build patches on periodic jobs

Change-Id: I0e3a7fae2c05e63cbe4a15e7b6d1bc6e5afdc323
diff --git a/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy b/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy
index 42c4b29..ebacea8 100644
--- a/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy
@@ -64,6 +64,11 @@
           " --set onos-classic.onosApiPort=30120 " +
           " --set onos-classic.onosOfPort=31653 " +
           " --set onos-classic.individualOpenFlowNodePorts=true " + testSpecificHelmFlags
+
+          if (gerritProject != "") {
+            localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
+          }
+
           volthaDeploy([
             infraNamespace: infraNamespace,
             volthaNamespace: volthaNamespace,
@@ -173,6 +178,19 @@
         ])
       }
     }
+    stage('Build patch') {
+      // build the patch only if gerritProject is specified
+      when {
+        expression {
+          return !gerritProject.isEmpty()
+        }
+      }
+      steps {
+        // NOTE that the correct patch has already been checked out
+        // during the getVolthaCode step
+        buildVolthaComponent("${gerritProject}")
+      }
+    }
     stage('Create K8s Cluster') {
       steps {
         script {
@@ -185,6 +203,16 @@
         }
       }
     }
+    stage('Load image in kind nodes') {
+      when {
+        expression {
+          return !gerritProject.isEmpty()
+        }
+      }
+      steps {
+        loadToKind()
+      }
+    }
     stage('Parse and execute tests') {
         steps {
           script {