Switch gating for reclass-system and CC templates on new salt-wrapper

Change-Id: Ie03a24b5dc48c302bec3d2bfe8aa40d11ea6895e
Related-Prod: PROD-25370 (PROD:25370)
diff --git a/gating-pipeline.groovy b/gating-pipeline.groovy
index 15518d4..d449cd8 100644
--- a/gating-pipeline.groovy
+++ b/gating-pipeline.groovy
@@ -19,9 +19,10 @@
 }
 
 def callJobWithExtraVars(String jobName) {
-    def gerritVars = JsonOutput.toJson(env.getEnvironment().findAll{ it.key.startsWith('GERRIT_') })
+    def gerritVars = env.getEnvironment().findAll{ it.key.startsWith('GERRIT_') }
+    gerritVars['GERRIT_CI_MERGE_TRIGGER'] = true
     testJob = build job: jobName, parameters: [
-        [$class: 'TextParameterValue', name: 'EXTRA_VARIABLES_YAML', value: gerritVars]
+        [$class: 'TextParameterValue', name: 'EXTRA_VARIABLES_YAML', value: JsonOutput.toJson(gerritVars) ]
     ]
     if (testJob.getResult() != 'SUCCESS') {
         error("Gate job ${testJob.getBuildUrl().toString()}  finished with ${testJob.getResult()} !")
@@ -56,10 +57,8 @@
                             gerritProject = gerritProject + "-latest"
                         }
                         def testJob = String.format("test-%s-%s", jobsNamespace, gerritProject)
-                        if (env.GERRIT_PROJECT == 'mk/cookiecutter-templates') {
-                            callJobWithExtraVars('test-mk-cookiecutter-templates')
-                        } else if (env.GERRIT_PROJECT == 'salt-models/reclass-system') {
-                            callJobWithExtraVars('test-salt-model-reclass-system')
+                        if (env.GERRIT_PROJECT == 'mk/cookiecutter-templates' || env.GERRIT_PROJECT == 'salt-models/reclass-system') {
+                            callJobWithExtraVars('test-salt-model-ci-wrapper')
                         } else {
                             if (isJobExists(testJob)) {
                                 common.infoMsg("Test job ${testJob} found, running")
diff --git a/test-salt-model-wrapper.groovy b/test-salt-model-wrapper.groovy
index ed3c723..339a30f 100644
--- a/test-salt-model-wrapper.groovy
+++ b/test-salt-model-wrapper.groovy
@@ -68,10 +68,10 @@
         def git = new com.mirantis.mk.Git()
         def python = new com.mirantis.mk.Python()
 
-        // Var TEST_PARAMETERS_YAML contains any additional parameters for tests,
+        // Var EXTRA_VARIABLES_YAML contains any additional parameters for tests,
         // like manually specified Gerrit Refs/URLs, additional parameters and so on
         def buildTestParams = [:]
-        def buildTestParamsYaml = env.getProperty('TEST_PARAMETERS_YAML')
+        def buildTestParamsYaml = env.getProperty('EXTRA_VARIABLES_YAML')
         if (buildTestParamsYaml) {
             common.mergeEnv(env, buildTestParamsYaml)
             buildTestParams = readYaml text: buildTestParamsYaml
@@ -91,6 +91,7 @@
         String gerritChangeNumber = job_env.get('GERRIT_CHANGE_NUMBER')
         String gerritPatchSetNumber = job_env.get('GERRIT_PATCHSET_NUMBER')
         String gerritBranch = job_env.get('GERRIT_BRANCH')
+        String gateMode = job_env.get('GERRIT_CI_MERGE_TRIGGER', false)
 
         // Common and manual build parameters
         LinkedHashMap projectsMap = [:]
@@ -175,11 +176,14 @@
                 branchJobName = 'test-mk-cookiecutter-templates'
                 branches[branchJobName] = runTests(branchJobName, yamlJobParameters(buildTestParams))
             }
-            if (gerritProject == cookiecutterTemplatesRepo) {
-                branchJobName = 'test-drivetrain'
-                branches[branchJobName] = runTests(branchJobName, yamlJobParameters(buildTestParams))
-                branchJobName = 'oscore-test-cookiecutter-models'
-                branches[branchJobName] = runTests(branchJobName, yamlJobParameters(buildTestParams))
+
+            if (!gateMode) {
+                if (gerritProject == cookiecutterTemplatesRepo) {
+                    branchJobName = 'test-drivetrain'
+                    branches[branchJobName] = runTests(branchJobName, yamlJobParameters(buildTestParams))
+                    branchJobName = 'oscore-test-cookiecutter-models'
+                    branches[branchJobName] = runTests(branchJobName, yamlJobParameters(buildTestParams))
+                }
             }
 
             branches.keySet().each { key ->