Updated SW-Upgrade master pipeline for Voltha Components base deployment tag

Change-Id: I2eec90e48b3edc40c67db6c3b0f77f0fccabd5e0
diff --git a/jjb/pipeline/voltha/master/software-upgrades.groovy b/jjb/pipeline/voltha/master/software-upgrades.groovy
index 0c259b9..f3e7a4c 100755
--- a/jjb/pipeline/voltha/master/software-upgrades.groovy
+++ b/jjb/pipeline/voltha/master/software-upgrades.groovy
@@ -25,7 +25,7 @@
 // returns the deployment version which is one less than the latest available tag of the repo, first voltha stack gets deployed using this;
 // returns the test version which is the latest tag of the repo, the component upgrade gets tested on this.
 // Note: if there is a major version change between deployment and test tags, then deployment tag will be same as test tag, i.e. both as latest.
-def get_voltha_comp_versions(component) {
+def get_voltha_comp_versions(component, base_deploy_tag) {
     def comp_test_tag = sh (
       script: "git ls-remote --refs --tags https://github.com/opencord/${component} | cut --delimiter='/' --fields=3 | tr '-' '~' | sort --version-sort | tail --lines=1 | sed 's/v//'",
       returnStdout: true
@@ -39,6 +39,10 @@
     if ( "${comp_deploy_major.trim()}" != "${comp_test_major.trim()}") {
       comp_deploy_tag = comp_test_tag
     }
+    if ( "${comp_test_tag.trim()}" == "${base_deploy_tag.trim()}") {
+      comp_deploy_tag = comp_test_tag
+      comp_test_tag = "master"
+    }
     println "${component}: deploy_tag: ${comp_deploy_tag}, test_tag: ${comp_test_tag}"
     return [comp_deploy_tag, comp_test_tag]
 }
@@ -91,13 +95,13 @@
       }
       if ("${name}" == "voltha-component-upgrade" || "${name}" == "voltha-component-rolling-upgrade") {
         // fetch voltha components versions/tags
-        (openolt_adapter_deploy_tag, openolt_adapter_test_tag) = get_voltha_comp_versions("voltha-openolt-adapter")
+        (openolt_adapter_deploy_tag, openolt_adapter_test_tag) = get_voltha_comp_versions("voltha-openolt-adapter", openoltAdapterDeployBaseTag.trim())
         extraHelmFlags = extraHelmFlags + " --set voltha-adapter-openolt.images.adapter_open_olt.tag=${openolt_adapter_deploy_tag} "
-        (openonu_adapter_deploy_tag, openonu_adapter_test_tag) = get_voltha_comp_versions("voltha-openonu-adapter-go")
+        (openonu_adapter_deploy_tag, openonu_adapter_test_tag) = get_voltha_comp_versions("voltha-openonu-adapter-go", openonuAdapterDeployBaseTag.trim())
         extraHelmFlags = extraHelmFlags + " --set voltha-adapter-openonu.images.adapter_open_onu_go.tag=${openonu_adapter_deploy_tag} "
-        (rw_core_deploy_tag, rw_core_test_tag) = get_voltha_comp_versions("voltha-go")
+        (rw_core_deploy_tag, rw_core_test_tag) = get_voltha_comp_versions("voltha-go", rwCoreDeployBaseTag.trim())
         extraHelmFlags = extraHelmFlags + " --set voltha.images.rw_core.tag=${rw_core_deploy_tag} "
-        (ofagent_deploy_tag, ofagent_test_tag) = get_voltha_comp_versions("ofagent-go")
+        (ofagent_deploy_tag, ofagent_test_tag) = get_voltha_comp_versions("ofagent-go", ofagentDeployBaseTag.trim())
         extraHelmFlags = extraHelmFlags + " --set voltha.images.ofagent.tag=${ofagent_deploy_tag} "
       }
       def localCharts = false
diff --git a/jjb/software-upgrades.yaml b/jjb/software-upgrades.yaml
index 8e1365c..cb328a8 100644
--- a/jjb/software-upgrades.yaml
+++ b/jjb/software-upgrades.yaml
@@ -25,6 +25,10 @@
           mcast-oar-url: 'https://oss.sonatype.org/content/groups/public/org/opencord/mcast-app/2.6.0-SNAPSHOT/mcast-app-2.6.0-20211227.170629-1.oar'
           kafka-version: '2.9.0.SNAPSHOT'
           kafka-oar-url: 'https://oss.sonatype.org/content/groups/public/org/opencord/kafka/2.9.0-SNAPSHOT/kafka-2.9.0-20211228.090937-1.oar'
+          openolt-adapter-deploy-base-tag: '4.2.2'
+          openonu-adapter-deploy-base-tag: '2.2.2'
+          rw-core-deploy-base-tag: '3.1.0'
+          ofagent-deploy-base-tag: '2.1.1'
           onu-image-version: 'BBSM_IMG_00002'
           onu-image-url: 'http://bbsim0:50074/images/software-image.img'
           onu-image-vendor: 'BBSM'
@@ -191,6 +195,26 @@
           description: 'ONOS Kafka App OAR File Url'
 
       - string:
+          name: openoltAdapterDeployBaseTag
+          default: '{openolt-adapter-deploy-base-tag}'
+          description: 'Minimum Version of OpenOLT Adapter to be used for Deployment'
+
+      - string:
+          name: openonuAdapterDeployBaseTag
+          default: '{openonu-adapter-deploy-base-tag}'
+          description: 'Minimum Version of OpenONU Adapter to be used for Deployment'
+
+      - string:
+          name: rwCoreDeployBaseTag
+          default: '{rw-core-deploy-base-tag}'
+          description: 'Minimum Version of RW Core to be used for Deployment'
+
+      - string:
+          name: ofagentDeployBaseTag
+          default: '{ofagent-deploy-base-tag}'
+          description: 'Minimum Version of Ofagent to be used for Deployment'
+
+      - string:
           name: onuImageVersion
           default: '{onu-image-version}'
           description: 'Version of ONU Image to Upgrade'