KaasUtils - render siTestsDockerImage

  * autoident

PRODX-5424

Change-Id: I776de30ee3590c6f68e16196afa33a0fc2bf1396
diff --git a/src/com/mirantis/mk/KaasUtils.groovy b/src/com/mirantis/mk/KaasUtils.groovy
index c28e00c..cc58774 100644
--- a/src/com/mirantis/mk/KaasUtils.groovy
+++ b/src/com/mirantis/mk/KaasUtils.groovy
@@ -8,29 +8,28 @@
 
 
 /**
-* Determine scope of test suite against per-commit KaaS deployment based on keywords
-* Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50
-*
-* Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
-* Example scheme:
-* New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and combine test-suite -> trigger deployment jobs from kaas/core
-* manage test-suite through Jenkins Job Parameters
-*
-* @return        (map)[
-*                    deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
-*                    runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
-*                   ]
-*/
+ * Determine scope of test suite against per-commit KaaS deployment based on keywords
+ * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50
+ *
+ * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
+ * Example scheme:
+ * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and combine test-suite -> trigger deployment jobs from kaas/core
+ * manage test-suite through Jenkins Job Parameters
+ *
+ * @return (map)[*                    deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
+ *                    runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
+ *                   ]
+ */
 def checkDeploymentTestSuite() {
     def common = new com.mirantis.mk.Common()
 
     // Available triggers and its sane defaults
-    def deployChild = (env.DEPLOY_CHILD_CLUSTER != null ) ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
-    def upgradeChild = (env.UPGRADE_CHILD_CLUSTER != null ) ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
-    def upgradeMgmt = (env.UPGRADE_MGMT_CLUSTER != null ) ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
-    def runUie2e = (env.RUN_UI_E2E != null ) ? env.RUN_UI_E2E.toBoolean() : false
-    def runMgmtConformance = (env.RUN_MGMT_CFM != null ) ? env.RUN_MGMT_CFM.toBoolean() : false
-    def runChildConformance = (env.RUN_CHILD_CFM != null ) ? env.RUN_CHILD_CFM.toBoolean() : false
+    def deployChild = (env.DEPLOY_CHILD_CLUSTER != null) ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
+    def upgradeChild = (env.UPGRADE_CHILD_CLUSTER != null) ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
+    def upgradeMgmt = (env.UPGRADE_MGMT_CLUSTER != null) ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
+    def runUie2e = (env.RUN_UI_E2E != null) ? env.RUN_UI_E2E.toBoolean() : false
+    def runMgmtConformance = (env.RUN_MGMT_CFM != null) ? env.RUN_MGMT_CFM.toBoolean() : false
+    def runChildConformance = (env.RUN_CHILD_CFM != null) ? env.RUN_CHILD_CFM.toBoolean() : false
     def fetchServiceBinaries = (env.FETCH_BINARIES_FROM_UPSTREAM != null) ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
     def awsOnDemandDemo = (env.RUN_AWS_ON_DEMAND_DEMO != null) ? env.RUN_AWS_ON_DEMAND_DEMO.toBoolean() : false
 
@@ -85,14 +84,14 @@
         Service binaries fetching scheduled: ${fetchServiceBinaries}
         Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#50""")
     return [
-        deployChildEnabled: deployChild,
-        upgradeChildEnabled: upgradeChild,
-        runChildConformanceEnabled: runChildConformance,
-        upgradeMgmtEnabled: upgradeMgmt,
-        runUie2eEnabled: runUie2e,
-        runMgmtConformanceEnabled: runMgmtConformance,
+        deployChildEnabled         : deployChild,
+        upgradeChildEnabled        : upgradeChild,
+        runChildConformanceEnabled : runChildConformance,
+        upgradeMgmtEnabled         : upgradeMgmt,
+        runUie2eEnabled            : runUie2e,
+        runMgmtConformanceEnabled  : runMgmtConformance,
         fetchServiceBinariesEnabled: fetchServiceBinaries,
-        awsOnDemandDemoEnabled: awsOnDemandDemo]
+        awsOnDemandDemoEnabled     : awsOnDemandDemo]
 }
 
 /**
@@ -104,8 +103,7 @@
  * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
  * manage refspecs through Jenkins Job Parameters
  *
- * @return        (map)[
- *                    siTests: (string) final refspec for si-tests
+ * @return (map)[*                    siTests: (string) final refspec for si-tests
  *                    siPipelines: (string) final refspec for si-pipelines
  *                   ]
  */
@@ -113,8 +111,9 @@
     def common = new com.mirantis.mk.Common()
 
     // Available triggers and its sane defaults
-    def siTestsRefspec = (env.SI_TESTS_REFSPEC != null ) ? env.SI_TESTS_REFSPEC : 'master'
-    def siPipelinesRefspec = (env.SI_PIPELINES_REFSPEC != null ) ? env.SI_PIPELINES_REFSPEC : 'master'
+    def siTestsRefspec = (env.SI_TESTS_REFSPEC != null) ? env.SI_TESTS_REFSPEC : 'master'
+    def siPipelinesRefspec = (env.SI_PIPELINES_REFSPEC != null) ? env.SI_PIPELINES_REFSPEC : 'master'
+    def siTestsDockerImage = (env.SI_TESTS_DOCKER_IMAGE != null) ? env.SI_TESTS_DOCKER_IMAGE : 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test:master'
     def commitMsg = (env.GERRIT_CHANGE_COMMIT_MESSAGE != null) ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
 
     def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
@@ -122,6 +121,8 @@
 
     if (siTestMatches.size() > 0) {
         siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
+        siTestsDockerImage = "docker-dev-local.docker.mirantis.net/review/" +
+            "kaas-si-test-${siTestsRefspec.split('/')[-2]}:${siTestsRefspec.split('/')[-1]}"
     }
     if (siPipelinesMatches.size() > 0) {
         siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
@@ -130,6 +131,7 @@
     common.infoMsg("""
         kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
         kaas/si-tests will be fetched from: ${siTestsRefspec}
+        kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}
         Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59""")
-    return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec]
+    return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage]
 }