[VOL-4114] Always sourcing the release file before kind-voltha commands

Change-Id: I123957db6e1212583c29a8b0c873cfcde721a390
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-DMI-bbsim-tests.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-DMI-bbsim-tests.groovy
index cbf04b8..4f45d15 100755
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-DMI-bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-DMI-bbsim-tests.groovy
@@ -64,6 +64,12 @@
     stage('Cleanup') {
       steps {
         sh """
+        if [ "${branch}" != "master" ]; then
+          echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+          source "$WORKSPACE/kind-voltha/releases/${branch}"
+        else
+          echo "on master, using default settings for kind-voltha"
+        fi
         cd $WORKSPACE/kind-voltha/
         WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
         """
@@ -168,6 +174,12 @@
          gzip *-combined.log || true
 
          ## shut down voltha but leave kind-voltha cluster
+         if [ "${branch}" != "master" ]; then
+           echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+           source "$WORKSPACE/kind-voltha/releases/${branch}"
+         else
+           echo "on master, using default settings for kind-voltha"
+         fi
          cd $WORKSPACE/kind-voltha/
          DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
          kubectl delete deployment voltctl || true
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-bbsim-tests.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-bbsim-tests.groovy
index 226b7e7..20573a7 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-bbsim-tests.groovy
@@ -332,6 +332,12 @@
         sh '''
            cd $WORKSPACE/kind-voltha/
            source $NAME-env.sh
+           if [ "${branch}" != "master" ]; then
+             echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
+           else
+             echo "on master, using default settings for kind-voltha"
+           fi
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
            # Workflow-specific flags
@@ -394,6 +400,12 @@
         sh '''
            cd $WORKSPACE/kind-voltha/
            source $NAME-env.sh
+           if [ "${branch}" != "master" ]; then
+             echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
+           else
+             echo "on master, using default settings for kind-voltha"
+           fi
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
            # Workflow-specific flags
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-dt-physical-build-and-tests.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-dt-physical-build-and-tests.groovy
index 42e253c..2ac34bf 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-dt-physical-build-and-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-dt-physical-build-and-tests.groovy
@@ -55,6 +55,12 @@
     stage ('Initialize') {
       steps {
         sh returnStdout: false, script: """
+        if [ "${branch}" != "master" ]; then
+          echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+          source "$WORKSPACE/kind-voltha/releases/${branch}"
+        else
+          echo "on master, using default settings for kind-voltha"
+        fi
         test -e $WORKSPACE/voltha/kind-voltha/voltha && cd $WORKSPACE/voltha/kind-voltha && ./voltha down
         cd $WORKSPACE
         rm -rf $WORKSPACE/*
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-go-multi-tests.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-go-multi-tests.groovy
index 984d4cb..ec77a7b 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-go-multi-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-go-multi-tests.groovy
@@ -161,6 +161,12 @@
          gzip *-combined.log || true
 
          ## shut down voltha but leave kind-voltha cluster
+         if [ "${branch}" != "master" ]; then
+           echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+           source "$WORKSPACE/kind-voltha/releases/${branch}"
+         else
+           echo "on master, using default settings for kind-voltha"
+         fi
          cd $WORKSPACE/kind-voltha/
          DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
          '''
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-go-tests.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-go-tests.groovy
index c8a80fd..bad26eb 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-go-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-go-tests.groovy
@@ -64,6 +64,12 @@
     stage('Cleanup') {
       steps {
         sh """
+        if [ "${branch}" != "master" ]; then
+          echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+          source "$WORKSPACE/kind-voltha/releases/${branch}"
+        else
+          echo "on master, using default settings for kind-voltha"
+        fi
         cd $WORKSPACE/kind-voltha/
         WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || true
         """
@@ -107,7 +113,6 @@
            fi
 
            EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags} "
-
            cd $WORKSPACE/kind-voltha/
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
            ./voltha up
@@ -174,6 +179,12 @@
          gzip *-combined.log || true
 
          ## shut down voltha but leave kind-voltha cluster
+         if [ "${branch}" != "master" ]; then
+           echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+           source "$WORKSPACE/kind-voltha/releases/${branch}"
+         else
+           echo "on master, using default settings for kind-voltha"
+         fi
          cd $WORKSPACE/kind-voltha/
          DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
          kubectl delete deployment voltctl || true
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-nightly-tests-bbsim.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-nightly-tests-bbsim.groovy
index d86aac9..d26be65 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-nightly-tests-bbsim.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-nightly-tests-bbsim.groovy
@@ -64,6 +64,12 @@
     stage('Cleanup') {
       steps {
         sh """
+        if [ "${branch}" != "master" ]; then
+          echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+          source "$WORKSPACE/kind-voltha/releases/${branch}"
+        else
+          echo "on master, using default settings for kind-voltha"
+        fi
         cd $WORKSPACE/kind-voltha/
         WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
         """
@@ -242,6 +248,12 @@
          gzip *-combined.log || true
 
          ## shut down voltha but leave kind-voltha cluster
+         if [ "${branch}" != "master" ]; then
+           echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+           source "$WORKSPACE/kind-voltha/releases/${branch}"
+         else
+           echo "on master, using default settings for kind-voltha"
+         fi
          cd $WORKSPACE/kind-voltha/
          DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
          kubectl delete deployment voltctl || true
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-openonu-go-test-bbsim.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-openonu-go-test-bbsim.groovy
index a82b9f1..7513557 100755
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-openonu-go-test-bbsim.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-openonu-go-test-bbsim.groovy
@@ -64,6 +64,12 @@
     stage('Cleanup') {
       steps {
         sh """
+        if [ "${branch}" != "master" ]; then
+          echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+          source "$WORKSPACE/kind-voltha/releases/${branch}"
+        else
+          echo "on master, using default settings for kind-voltha"
+        fi
         cd $WORKSPACE/kind-voltha/
         WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
         """
@@ -144,6 +150,12 @@
       }
       steps {
         sh '''
+          if [ "${branch}" != "master" ]; then
+            echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+            source "$WORKSPACE/kind-voltha/releases/${branch}"
+          else
+            echo "on master, using default settings for kind-voltha"
+          fi
           cd $WORKSPACE/kind-voltha/
           WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -189,6 +201,12 @@
       }
       steps {
         sh '''
+          if [ "${branch}" != "master" ]; then
+            echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+            source "$WORKSPACE/kind-voltha/releases/${branch}"
+          else
+            echo "on master, using default settings for kind-voltha"
+          fi
           cd $WORKSPACE/kind-voltha/
           WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -235,6 +253,12 @@
       }
       steps {
         sh '''
+           if [ "${branch}" != "master" ]; then
+             echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
+           else
+             echo "on master, using default settings for kind-voltha"
+           fi
            cd $WORKSPACE/kind-voltha/
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -281,6 +305,12 @@
       }
       steps {
         sh '''
+           if [ "${branch}" != "master" ]; then
+             echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
+           else
+             echo "on master, using default settings for kind-voltha"
+           fi
            cd $WORKSPACE/kind-voltha/
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -333,6 +363,12 @@
       }
       steps {
         sh '''
+           if [ "${branch}" != "master" ]; then
+             echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
+           else
+             echo "on master, using default settings for kind-voltha"
+           fi
            cd $WORKSPACE/kind-voltha/
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -391,6 +427,12 @@
       }
       steps {
         sh '''
+           if [ "${branch}" != "master" ]; then
+             echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
+           else
+             echo "on master, using default settings for kind-voltha"
+           fi
            cd $WORKSPACE/kind-voltha/
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-physical-build-and-tests.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-physical-build-and-tests.groovy
index e719a08..f0b6787 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-physical-build-and-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-physical-build-and-tests.groovy
@@ -63,6 +63,12 @@
     stage ('Initialize') {
       steps {
         sh returnStdout: false, script: """
+        if [ "${branch}" != "master" ]; then
+          echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+          source "$WORKSPACE/kind-voltha/releases/${branch}"
+        else
+          echo "on master, using default settings for kind-voltha"
+        fi
         test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down
         cd $WORKSPACE
         rm -rf $WORKSPACE/*
diff --git a/jjb/pipeline/voltha/voltha-2.7/voltha-system-test-bbsim.groovy b/jjb/pipeline/voltha/voltha-2.7/voltha-system-test-bbsim.groovy
index 991ecee..d05077d 100644
--- a/jjb/pipeline/voltha/voltha-2.7/voltha-system-test-bbsim.groovy
+++ b/jjb/pipeline/voltha/voltha-2.7/voltha-system-test-bbsim.groovy
@@ -149,6 +149,12 @@
          extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
 
          ## shut down kind-voltha
+         if [ "${branch}" != "master" ]; then
+           echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
+           source "$WORKSPACE/kind-voltha/releases/${branch}"
+         else
+           echo "on master, using default settings for kind-voltha"
+         fi
          cd $WORKSPACE/kind-voltha
 	       WAIT_ON_DOWN=y ./voltha down