[refactor][core] parse config file for component job triggering

us: PRODX-6088
Change-Id: I63b279f47e1d5dc285343b733239926cd0a8dcb6
diff --git a/src/com/mirantis/mk/KaasUtils.groovy b/src/com/mirantis/mk/KaasUtils.groovy
index 8d4a441..d56d496 100644
--- a/src/com/mirantis/mk/KaasUtils.groovy
+++ b/src/com/mirantis/mk/KaasUtils.groovy
@@ -113,13 +113,11 @@
 
     // Available triggers and its sane defaults
     def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
-    def siTestsFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
     def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
     def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test:master'
     def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
 
     def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
-    def siFeatureFlagsMatches = (commitMsg =~ /(\[si-feature-flags\s.*?\])/)
     def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
 
     if (siTestMatches.size() > 0) {
@@ -127,9 +125,6 @@
         siTestsDockerImage = "docker-dev-local.docker.mirantis.net/review/" +
             "kaas-si-test-${siTestsRefspec.split('/')[-2]}:${siTestsRefspec.split('/')[-1]}"
     }
-    if (siFeatureFlagsMatches.size() > 0) {
-        siTestsFeatureFlags = siFeatureFlagsMatches[0][0].split('si-feature-flags')[1].replaceAll('[\\[\\]]', '').trim()
-    }
     if (siPipelinesMatches.size() > 0) {
         siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
     }
@@ -138,13 +133,12 @@
         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}
-        kaas/si-tests additional feature flags applied: [${siTestsFeatureFlags}]
         Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template#59""")
-    return [siTests: siTestsRefspec, siFeatureFlags: siTestsFeatureFlags, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage]
+    return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage]
 }
 
 /**
- * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
+ * Parse additional configuration for kaas component CICD repo
  * @param configurationFile    (str) path to configuration file in yaml format
  *
  * @return                     (map)[     siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
@@ -218,10 +212,11 @@
  * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/.git-message-template
  * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
  *
- * @param:        (string) component name [iam, lcm, stacklight]
- * @param:        (string) Patch for kaas/cluster releases in json format
+ * @param:        component (string) component name [iam, lcm, stacklight]
+ * @param:        patchSpec (string) Patch for kaas/cluster releases in json format
+ * @param:        configurationFile (string) Additional file for component repo CI config in yaml format
  */
-def triggerPatchedComponentDemo(component, patchSpec) {
+def triggerPatchedComponentDemo(component, patchSpec, configurationFile = '.ci-parameters.yaml') {
     def common = new com.mirantis.mk.Common()
     // Determine if custom trigger keywords forwarded from gerrit
     def triggers = checkDeploymentTestSuite()
@@ -230,12 +225,25 @@
     // Determine Core refspecs
     def coreRefspec = checkCustomCoreRefspec()
 
+    // Determine component repo ci configuration
+    def ciSpec = [:]
+    def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
+    if (fileExists(configurationFile)) {
+        common.infoMsg('Component CI configuration file detected, parsing...')
+        ciSpec = parseKaaSComponentCIParameters(configurationFile)
+        componentFeatureFlags = ciSpec['siTestsFeatureFlags']
+    } else {
+        common.warningMsg('''Component CI configuration file is not exists,
+            several code-management features may be unavailable, follow *link* to create configuration file''')
+    }
+
+
     def jobs = [:]
     def parameters = [
         string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
         string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
         string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
-        string(name: 'SI_TESTS_FEATURE_FLAGS', value: siRefspec.siFeatureFlags),
+        string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
         string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
         string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
         booleanParam(name: 'UPGRADE_MGMT', value: triggers.upgradeMgmtEnabled),