Merge "Add email settings for services-ci"
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 17ab32c..a85196c 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -1208,6 +1208,24 @@
     return v1 >= v2
 }
 
+/**
+ * Sort array of versions. Returns sorted array (ascending)
+ * @param ArrayList versions
+ */
+def sortVersions (ArrayList versions) {
+    for (int i = 0; i < versions.size(); i++) {
+        for (int j = 0; j < versions.size() - i - 1; j++) {
+            if (isVerGreaterOrEqual(versions[j], versions[j + 1])) {
+                def temp = versions[j]
+                versions[j] = versions[j + 1]
+                versions[j + 1] = temp
+            }
+        }
+    }
+
+    return versions
+}
+
 def readYaml2(LinkedHashMap kwargs) {
     /**
      *  readYaml wrapper to workaround case when initial file contains
diff --git a/src/com/mirantis/mk/KaasUtils.groovy b/src/com/mirantis/mk/KaasUtils.groovy
index 2526a9c..880e365 100644
--- a/src/com/mirantis/mk/KaasUtils.groovy
+++ b/src/com/mirantis/mk/KaasUtils.groovy
@@ -100,6 +100,7 @@
     def auditd = env.AUDITD_ENABLE ? env.AUDITD_ENABLE.toBoolean() : false
     def customSlackChannel = env.SLACK_CHANNEL_NOTIFY ? env.SLACK_CHANNEL_NOTIFY : ''
     def runNTPUpdateTest = env.RUN_NTP_UPDATE_TEST ? env.RUN_NTP_UPDATE_TEST.toBoolean() : false
+    def runMCCMariaBackupRestoreTest = env.RUN_MCC_MARIA_BACKUP_RESTORE_TEST ? env.RUN_MCC_MARIA_BACKUP_RESTORE_TEST.toBoolean() : false
     // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
     def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
         enabled: false,
@@ -141,6 +142,9 @@
     def enableBv2Smoke = true
     def runCacheWarmup = env.CACHE_WARMUP_ENABLED ? env.CACHE_WARMUP_ENABLED.toBoolean() : false
     def cveScan = false
+    // Sync to public CDN is triggered automatically for corresponding scenarios
+    // This trigger is used only for on-demand cases
+    def publicCISync = false
 
     def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
     if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
@@ -400,6 +404,11 @@
         common.errorMsg('CVE Scan job enabled')
     }
 
+    if (commitMsg ==~ /(?s).*\[public-ci-sync\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*public-ci-sync\.*/) {
+        publicCISync = true
+        common.errorMsg('Sync to public-ci CDN is enabled')
+    }
+
     def slackChannelMatches = (commitMsg =~ /(\[slack-channel\s*[#@](\S+)])/)
     if (slackChannelMatches.size() > 0) {
         // override chanenel notify when it set explicitly
@@ -453,6 +462,11 @@
         common.warningMsg('After deployment of mgmt job with NTP update will be executed')
     }
 
+    if (commitMsg ==~ /(?s).*\[mcc-maria-backup-restore\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mcc-maria-backup-restore\.*/) {
+        runMCCMariaBackupRestoreTest = true
+        common.warningMsg('MCC Maria Backup/Restore test will be executed as part of mgmt test suite')
+    }
+
     if (commitMsg ==~ /(?s).*\[internal-ntp\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*internal-ntp\.*/ || proxyConfig['mgmtOffline'] || proxyConfig['childOffline']) {
         configureInternalNTP = true
         openstackIMC = 'eu'
@@ -667,6 +681,8 @@
         CVE Scan enabled: ${cveScan}
         Keycloak+LDAP integration enabled: ${coreKeycloakLdap}
         NTP update job scheduled: ${runNTPUpdateTest}
+        MCC MariaDB Backup/Restore test enabled: ${runMCCMariaBackupRestoreTest}
+        Sync to public-ci CDN enabled: ${publicCISync}
         Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
     return [
         osCloudLocation                          : openstackIMC,
@@ -747,6 +763,8 @@
         coreKeycloakLdapEnabled                  : coreKeycloakLdap,
         internalNTPServersEnabled                : configureInternalNTP,
         runNTPUpdateTestEnabled                  : runNTPUpdateTest,
+        runMCCMariaBackupRestoreTestEnabled      : runMCCMariaBackupRestoreTest,
+        publicCISyncEnabled                      : publicCISync,
     ]
 }
 
@@ -1072,7 +1090,8 @@
         booleanParam(name: "AUDITD_ENABLE", value: triggers.auditdEnabled),
         booleanParam(name: 'CORE_KEYCLOAK_LDAP_ENABLED', value: triggers.coreKeycloakLdapEnabled),
         booleanParam(name: 'CORE_KAAS_NTP_ENABLED', value: triggers.internalNTPServersEnabled),
-        booleanParam(name: 'RUN_NTP_UPDATE_TEST', value: triggers.runNTPUpdateTestEnabled)
+        booleanParam(name: 'RUN_NTP_UPDATE_TEST', value: triggers.runNTPUpdateTestEnabled),
+        booleanParam(name: 'RUN_MCC_MARIA_BACKUP_RESTORE_TEST', value: triggers.runMCCMariaBackupRestoreTestEnabled)
     ]
 
     // customize multiregional demo