blob: 4ade7d8fe643d7e3d3ad43cd5b340bd5576c87a1 [file] [log] [blame]
vnaumov33747e12020-05-04 17:35:20 +02001package com.mirantis.mk
vnaumov33747e12020-05-04 17:35:20 +02002
3/**
4 *
5 * KaaS Component Testing Utilities
6 *
7 */
8
Владислав Наумовe5345812020-08-12 16:30:20 +02009/**
10 * Check KaaS Core CICD feature flags
11 * such triggers can be used in case of switching between pipelines,
12 * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself
13 *
14 * @return (map)[
15 * ffNameEnabled: (bool) True/False
16 * ]
17 */
18def checkCoreCIFeatureFlags() {
19 def common = new com.mirantis.mk.Common()
20 def ff = [
21 build_artifacts_upgrade: false,
22 ]
23
24 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
25 if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) {
26 ff['build_artifacts_upgrade'] = true
27 }
28
29 common.infoMsg("Core ci feature flags status: ${ff}")
30 return ff
31}
vnaumov33747e12020-05-04 17:35:20 +020032
33/**
azvyagintseva12230a2020-06-05 13:24:06 +030034 * Determine scope of test suite against per-commit KaaS deployment based on keywords
Владислав Наумов81777472021-03-09 15:14:27 +040035 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
azvyagintseva12230a2020-06-05 13:24:06 +030036 *
37 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
38 * Example scheme:
Владислав Наумовe5345812020-08-12 16:30:20 +020039 * New CR pushed in kubernetes/lcm-ansible -> parsing it'cs commit body and combine test-suite -> trigger deployment jobs from kaas/core
azvyagintseva12230a2020-06-05 13:24:06 +030040 * manage test-suite through Jenkins Job Parameters
41 *
Владислав Наумов6c2afff2020-06-05 12:54:53 +020042 * @return (map)[
43 * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
44 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
azvyagintseva12230a2020-06-05 13:24:06 +030045 * ]
46 */
vnaumov33747e12020-05-04 17:35:20 +020047def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020048 def common = new com.mirantis.mk.Common()
49
vnaumov33747e12020-05-04 17:35:20 +020050 // Available triggers and its sane defaults
Владислав Наумов44c64b72020-12-04 20:22:53 +010051 def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020052 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
53 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov38ee4382022-01-27 16:21:51 +040054 def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false
55 def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040056 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
slalov021171f2022-03-04 14:48:38 +040057 def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false
Владислав Наумов0dc99252020-11-13 13:30:48 +010058 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010059 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010060 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040061 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020062 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040063 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020064 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
65 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020066 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020067 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
slalov574123e2022-04-06 17:24:19 +040068 def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020069 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
70 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010071 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040072 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020073 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
74 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
75 enabled: false,
76 managementLocation: '',
77 regionLocation: '',
78 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020079
Владислав Наумовb8305e22021-02-10 17:23:12 +010080 // proxy customization
81 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020082 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
83 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020084 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010085 ]
86
Владислав Наумов4eb1da32020-08-31 14:45:16 +020087 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020088 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020089 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +020090 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +020091 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +020092 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +020093 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +040094 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +020095 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +030096 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +040097 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +040098 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
vnaumov33747e12020-05-04 17:35:20 +020099
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200100 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100101 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
102 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200103 common.warningMsg('Forced running offline mgmt deployment, some provider CDN regions for mgmt deployment may be set to *public-ci* to verify proxy configuration')
Владислав Наумовb8305e22021-02-10 17:23:12 +0100104 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100105 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
106 seedMacOs = true
107 }
slalov574123e2022-04-06 17:24:19 +0400108 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200109 deployChild = true
110 }
111 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
112 deployChild = true
113 upgradeChild = true
114 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400115 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
116 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400117 // override child version when it set explicitly
118 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400119 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400120 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
121 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400122 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
123 mosDeployChild = true
124 }
125 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
126 mosDeployChild = true
127 mosUpgradeChild = true
128 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100129 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
130 attachBYO = true
131 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100132 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
133 attachBYO = true
134 upgradeBYO = true
135 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400136
137 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
138 if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/ || byoDeployMatches.size() > 0) {
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100139 runBYOMatrix = true
140
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400141 if (byoDeployMatches.size() > 0) {
142 defaultBYOOs = byoDeployMatches[0][2]
143 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
144 }
145
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100146 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
147 attachBYO = false
148 upgradeBYO = false
149 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400150 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200151 upgradeMgmt = true
152 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400153 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
154 enableLMALogging = true
155 }
vnaumov33747e12020-05-04 17:35:20 +0200156 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
157 runUie2e = true
158 }
159 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
160 runMgmtConformance = true
161 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200162 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
163 runMgmtUserControllerTest = true
164 }
slalov574123e2022-04-06 17:24:19 +0400165 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
166 runProxyChildTest = true
167 deployChild = true
168 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
169 }
vnaumov33747e12020-05-04 17:35:20 +0200170 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
171 runChildConformance = true
172 deployChild = true
173 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200174 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
175 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400176 enableLMALogging = true
177 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400178 }
slalov13e579c2022-01-31 21:37:02 +0400179 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
180 runMaintenanceTest = true
181 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200182 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
183 proxyConfig['childOffline'] = true
184 deployChild = true
185 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200186 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
187 proxyConfig['childOffline'] = true
188 proxyConfig['childProxy'] = true
189 deployChild = true
190 }
vnaumov33747e12020-05-04 17:35:20 +0200191 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
192 fetchServiceBinaries = true
193 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200194 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400195 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200196 common.warningMsg('Forced running child cluster deployment on EQUINIX METAL provider based on AWS management cluster, triggered on patchset using custom keyword: \'[equinix-on-aws]\' ')
eromanovadf247c32020-12-25 15:44:13 +0400197 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200198 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
199 azureOnAwsDemo = true
200 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
201 }
202 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
203 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
204 attachBYO ||
205 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100206 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200207 seedMacOs ||
208 equinixOnAwsDemo ||
209 azureOnAwsDemo) {
210
vnaumov33747e12020-05-04 17:35:20 +0200211 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200212 common.warningMsg('Running additional kaas deployment with AWS provider, may be forced due applied trigger cross dependencies, follow docs to clarify info')
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200213 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200214 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200215 equinixOnDemandDemo = true
216 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200217 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200218 equinixMetalV2OnDemandDemo = true
219 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100220 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
221 equinixMetalV2OnDemandDemo = true
222 equinixMetalV2ChildDiffMetro = true
223 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200224 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
225 azureOnDemandDemo = true
226 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200227 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
228 enableOSDemo = false
229 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200230 }
231
azvyagintsev1761bdc2020-09-04 17:24:12 +0300232 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
233 enableBMDemo = false
234 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
235 }
236
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400237 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
238 enableVsphereDemo = false
239 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
240 }
241
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400242 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
243 enableArtifactsBuild = false
244 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
245 }
246
vnaumov33747e12020-05-04 17:35:20 +0200247 // TODO (vnaumov) remove below condition after moving all releases to UCP
248 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
249 if (ucpChildMatches.size() > 0) {
250 deployChild = true
251 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
252
253 // TODO(vnaumov) delete after ucp upgrades support
254 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
255 upgradeChild = false
256 }
257
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200258 // multiregional tests
259 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
260 if (multiRegionalMatches.size() > 0) {
261 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
262 }
263 switch (multiregionalMappings['managementLocation']) {
264 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100265 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200266 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100267
268 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
269 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
270 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200271 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200272 case 'os':
273 if (enableOSDemo == false) {
274 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
275 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200276 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200277 case 'vsphere':
278 if (enableVsphereDemo == false) {
279 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
280 }
281 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200282 case 'equinix':
283 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
284 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400285 break
eromanova8c702ae2021-12-24 17:43:12 +0400286 case 'equinixmetalv2':
287 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
288 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400289 break
slalovfd0b7e62021-07-28 18:05:16 +0400290 case 'azure':
291 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
292 azureOnDemandDemo = true
293 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200294 }
295
Владислав Наумовb8305e22021-02-10 17:23:12 +0100296 // CDN configuration
297 def cdnConfig = [
298 mgmt: [
299 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200300 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100301 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200302 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200303 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200304 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100305 ]
306
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400307 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
308 openstackIMC = 'eu'
309 // use internal-eu because on internal-ci with eu cloud image pull takes much time
310 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
311 common.infoMsg("eu-demo was triggered, force switching CDN region to ${cdnRegion}")
312 cdnConfig['mgmt']['openstack'] = cdnRegion
313 }
slalov021171f2022-03-04 14:48:38 +0400314 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
315 openstackIMC = 'eu2'
316 MosTfDeploy = true
317 // use internal-eu because on internal-ci with eu cloud image pull takes much time
318 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
319 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
320 cdnConfig['mgmt']['openstack'] = cdnRegion
321 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400322
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100323 // calculate weight of current demo run to manage lockable resources
324 def demoWeight = (deployChild) ? 2 : 1 // management = 1, child = 1
325
vnaumov33747e12020-05-04 17:35:20 +0200326 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400327 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100328 CDN deployment configuration: ${cdnConfig}
329 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100330 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200331 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400332 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200333 Child cluster release upgrade scheduled: ${upgradeChild}
slalov021171f2022-03-04 14:48:38 +0400334 Mos-Tf deploy: ${mosTfDeploy}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400335 MOS child deploy scheduled: ${mosDeployChild}
336 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200337 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100338 Single BYO cluster attachment scheduled: ${attachBYO}
339 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
340 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400341 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200342 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400343 Mgmt LMA logging enabled: ${enableLMALogging}
vnaumov33747e12020-05-04 17:35:20 +0200344 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200345 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200346 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200347 Mgmt UI e2e testing scheduled: ${runUie2e}
slalov13e579c2022-01-31 21:37:02 +0400348 Maintenance test: ${runMaintenanceTest}
slalov574123e2022-04-06 17:24:19 +0400349 Child proxy test: ${runProxyChildTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200350 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200351 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200352 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100353 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200354 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200355 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200356 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400357 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200358 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300359 BM provider deployment scheduled: ${enableBMDemo}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400360 Artifacts build scheduled: ${enableArtifactsBuild}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200361 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200362 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100363 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Владислав Наумов81777472021-03-09 15:14:27 +0400364 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200365 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400366 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100367 cdnConfig : cdnConfig,
368 proxyConfig : proxyConfig,
369 useMacOsSeedNode : seedMacOs,
370 deployChildEnabled : deployChild,
371 childDeployCustomRelease : customChildRelease,
372 upgradeChildEnabled : upgradeChild,
slalov021171f2022-03-04 14:48:38 +0400373 mosTfDeployEnabled : mosTfDeploy,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400374 mosDeployChildEnabled : mosDeployChild,
375 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100376 runChildConformanceEnabled : runChildConformance,
377 attachBYOEnabled : attachBYO,
378 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100379 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400380 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100381 upgradeMgmtEnabled : upgradeMgmt,
382 enableLMALoggingEnabled : enableLMALogging,
383 runUie2eEnabled : runUie2e,
384 runMgmtConformanceEnabled : runMgmtConformance,
slalov13e579c2022-01-31 21:37:02 +0400385 runMaintenanceTestEnable : runMaintenanceTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100386 runLMATestEnabled : runLMATest,
387 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400388 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100389 fetchServiceBinariesEnabled : fetchServiceBinaries,
390 awsOnDemandDemoEnabled : awsOnDemandDemo,
391 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
392 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
393 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
394 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
395 azureOnDemandDemoEnabled : azureOnDemandDemo,
396 azureOnAwsDemoEnabled : azureOnAwsDemo,
397 vsphereDemoEnabled : enableVsphereDemo,
398 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
399 bmDemoEnabled : enableBMDemo,
400 osDemoEnabled : enableOSDemo,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400401 artifactsBuildEnabled : enableArtifactsBuild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100402 multiregionalConfiguration : multiregionalMappings,
403 demoWeight : demoWeight]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200404}
405
406/**
407 * Determine management and regional setup for demo workflow scenario
408 *
409 *
410 * @param: keyword (string) string , represents keyworkd trigger, specified in gerrit commit body, like `[multiregion aws,os]`
411 or Jenkins environment string variable in form like 'aws,os'
412 * @return (map)[
413 enabled: (bool),
414 * managementLocation: (string), //aws,os
415 * regionLocation: (string), //aws,os
416 * ]
417 */
418def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200419 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400420 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
421 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200422
423 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200424 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200425 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
426 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
427 } else {
428 common.infoMsg('Multiregion definition configured via environment variable')
429 clusterTypes = keyword.trim().split(',')
430 }
431
432 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100433 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200434 }
435
Владислав Наумовf793fe32020-09-11 15:19:19 +0200436 def desiredManagementProvider = clusterTypes[0].trim()
437 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200438 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
439 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200440 management providers list - ${supportedManagementProviders}
441 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200442 }
443
444 return [
445 enabled: true,
446 managementLocation: desiredManagementProvider,
447 regionLocation: desiredRegionalProvider,
448 ]
vnaumov33747e12020-05-04 17:35:20 +0200449}
450
451/**
452 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
453
Владислав Наумов81777472021-03-09 15:14:27 +0400454 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
vnaumov33747e12020-05-04 17:35:20 +0200455 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
456 * Example scheme:
457 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
458 * manage refspecs through Jenkins Job Parameters
459 *
azvyagintseva12230a2020-06-05 13:24:06 +0300460 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200461 * siPipelines: (string) final refspec for si-pipelines
462 * ]
463 */
464def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200465 def common = new com.mirantis.mk.Common()
466
vnaumov33747e12020-05-04 17:35:20 +0200467 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200468 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
469 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200470 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
471 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200472 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200473
474 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
475 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
476
477 if (siTestMatches.size() > 0) {
478 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400479 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200480 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200481 }
482 if (siPipelinesMatches.size() > 0) {
483 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
484 }
485
486 common.infoMsg("""
487 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
488 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200489 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400490 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200491 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200492}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200493
Владислав Наумов9080f372020-06-08 13:57:16 +0200494/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200495 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200496 * @param configurationFile (str) path to configuration file in yaml format
497 *
498 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
499 * ]
500 */
501def parseKaaSComponentCIParameters(configurationFile){
502 def common = new com.mirantis.mk.Common()
503 def ciConfig = readYaml file: configurationFile
504 def ciSpec = [
505 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
506 ]
507
508 if (ciConfig.containsKey('si-tests-feature-flags')) {
509 common.infoMsg("""SI tests feature flags customization detected,
510 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
511
512 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
513 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200514
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200515 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200516 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
517 }
518
519 common.infoMsg("""Additional ci configuration parsed successfully:
520 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}""")
521 return ciSpec
522}
523
524/**
525 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200526
Владислав Наумов81777472021-03-09 15:14:27 +0400527 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
Владислав Наумов9080f372020-06-08 13:57:16 +0200528 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
529 * Example scheme:
530 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
531 * manage refspecs through Jenkins Job Parameters
532 *
533 * @return (map)[ core: (string) final refspec for kaas/core
534 * corePipelines: (string) final refspec for pipelines in kaas/core
535 * ]
536 */
537def checkCustomCoreRefspec() {
538 def common = new com.mirantis.mk.Common()
539
540 // Available triggers and its sane defaults
541 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
542 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
543 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
544 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
545
546 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
547 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
548
549 if (coreMatches.size() > 0) {
550 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
551 }
552 if (corePipelinesMatches.size() > 0) {
553 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
554 }
555
556 common.infoMsg("""
557 kaas/core will be fetched from: ${coreRefspec}
558 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400559 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200560 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
561}
562
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200563
564/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200565 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
566 * needed to forward inside kaas core set of jobs
567 *
568 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
569 * @return (list)[ string(name: '', value: ''),
570 * ]
571 */
572def generateKaaSVarsFromContext(context) {
573 def common = new com.mirantis.mk.Common()
574 def parameters = []
575 def config = readYaml text: context
576
577 config.each { k,v ->
578 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
579 parameters.add(string(name: k, value: v))
580 }
581
582 return parameters
583}
584
585/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200586 * Trigger KaaS demo jobs based on AWS/OS providers with customized test suite, parsed from external sources (gerrit commit/jj vars)
Владислав Наумов81777472021-03-09 15:14:27 +0400587 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200588 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
589 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200590 * @param: component (string) component name [iam, lcm, stacklight]
591 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
592 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200593 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200594def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200595 def common = new com.mirantis.mk.Common()
596 // Determine if custom trigger keywords forwarded from gerrit
597 def triggers = checkDeploymentTestSuite()
598 // Determine SI refspecs
599 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200600 // Determine Core refspecs
601 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200602
Владислав Наумов418042b2020-07-09 18:31:10 +0200603 // Determine component repo ci configuration
604 def ciSpec = [:]
605 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
606 if (fileExists(configurationFile)) {
607 common.infoMsg('Component CI configuration file detected, parsing...')
608 ciSpec = parseKaaSComponentCIParameters(configurationFile)
609 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
610 } else {
611 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200612 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200613 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
614 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200615 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400616
617 def platforms = []
618 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
619 // Currently only vsphere demo is required for IPAM component
620 platforms.add('vsphere')
621 } else {
622 if (triggers.osDemoEnabled) {
623 platforms.add('openstack')
624 }
625 if (triggers.awsOnDemandDemoEnabled) {
626 platforms.add('aws')
627 }
628 if (triggers.equinixOnDemandDemoEnabled) {
629 platforms.add('equinix')
630 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200631 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
632 platforms.add('equinixmetalv2')
633 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200634 if (triggers.azureOnDemandDemoEnabled) {
635 platforms.add('azure')
636 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400637 if (triggers.vsphereDemoEnabled) {
638 platforms.add('vsphere')
639 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400640 }
641
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200642 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200643 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200644 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
645 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200646 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200647 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200648 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
649 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200650 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200651 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400652 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400653 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100654 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200655 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200656 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100657 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
slalov021171f2022-03-04 14:48:38 +0400658 booleanParam(name: 'MOS_TF_DEPLOY', value: triggers.mosTfDeployEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200659 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400660 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200661 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200662 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov13e579c2022-01-31 21:37:02 +0400663 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnable),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200664 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200665 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200666 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
667 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400668 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100669 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100670 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100671 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200672 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400673 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200674 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200675 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100676 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400677 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200678 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200679 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200680 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200681
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200682 // customize multiregional demo
683 if (triggers.multiregionalConfiguration.enabled) {
684 parameters.add(string(name: 'MULTIREGION_SETUP',
685 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
686 ))
687 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200688
Владислав Наумов92288d92020-07-13 18:36:21 +0200689 // Determine component team custom context
690 if (coreContext != '') {
691 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
692 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200693 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200694 }
695
Владислав Наумовaa430612020-06-08 17:18:31 +0200696 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400697
698 platforms.each { platform ->
699 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000700 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400701 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
702 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
703 def build_description = job_info.getDescription()
704 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000705 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200706
Vladislav Naumov5313a202021-04-07 17:13:39 +0000707 if (build_description) {
708 currentBuild.description += build_description
709 }
710 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400711 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000712 }
713 }
714 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200715
716 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400717 if (jobs.size() == 0) {
718 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
719 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200720 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
721 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200722
723 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200724 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200725 currentBuild.result = 'FAILURE'
726 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200727}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200728
729
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400730/**
731 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200732 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400733 *
734 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
735 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
736 * @param: multiregionalConfiguration (map) Multiregional configuration
737 * @return (map) Return aggregated map with lockResources and netMap
738 */
739
740
741def generateLockResources(callBackDemo, triggers) {
742 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200743 def netMap = [
744 vsphere: [:],
745 equinix: [:],
746 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400747 // Define vsphere locklabels with initial quantity
748 def lockLabels = [
749 vsphere_networking_core_ci: 0,
750 vsphere_offline_networking_core_ci: 0,
751 ]
752 def deployChild = triggers.deployChildEnabled
753 def multiregionConfig = triggers.multiregionalConfiguration
754 def runMultiregion = multiregionConfig.enabled
755
756 // Generate vsphere netMap and lockLabels based on demo context
757 switch (callBackDemo) {
758 case 'aws':
759 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
760 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400761 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400762
763 // Define netMap for Vsphere region
Владислав Наумовf60480d2021-10-15 14:04:01 +0200764 if (runMultiregion && multiregionConfig.managementLocation == 'aws' &&
765 multiregionConfig.regionLocation == 'vsphere') {
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400766 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200767 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400768 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200769 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400770 }
771 break
772 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200773 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400774 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200775 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400776 }
777 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
778 multiregionConfig.regionLocation == 'vsphere') {
779 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200780 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400781 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200782 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400783 }
784 break
785 default:
786 error('Supposed to be called from aws or vsphere demos only')
787 }
788
789 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
790 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200791 netMap['vsphere'].each { clusterType, netConfig ->
792 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
793 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
794 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
795
796 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400797 lockLabels['vsphere_offline_networking_core_ci']++
798 } else {
799 lockLabels['vsphere_networking_core_ci']++
800 }
801 }
802
803 // generate lock metadata
804 def lockResources = []
805 lockLabels.each { label, quantity ->
806 if (quantity > 0) {
807 def res = [
808 label: label,
809 quantity: quantity,
810 ]
811 lockResources.add(res)
812 }
813 }
814
815 common.infoMsg("""Generated vsphere netMap: ${netMap}
816 Generated lockResources: ${lockResources}""")
817
818 return [
819 netMap: netMap,
820 lockResources: lockResources,
821 ]
822}
823
824/**
825 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
826 * and empty rangeConfig to the this map.
827 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200828 * @param: netMap (string) vsphere, equinix netMap or empty map
829 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400830 * @param: clusterType (string) Vsphere cluster type
831 */
832
Владислав Наумов33e1e812021-08-17 17:09:25 +0200833def addToProviderNetMap (netMap, provider, clusterType) {
834 switch (provider) {
835 case 'equinix':
836 netMap[provider][clusterType] = [
837 vlanConfig: '',
838 ]
839 break
840 case 'vsphere':
841 netMap[provider][clusterType] = [
842 netName: 'default',
843 rangeConfig: '',
844 ]
845 break
846 default:
847 error('Net map locks supported for Equinix/Vsphere providers only')
848 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400849}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300850
851/**
852* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
853* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
854* If keyword contains only 'key' part then 'value' is boolean True.
855* This function does not perform keywords validation.
856* First line of a commit message is ignored.
857* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
858* TODO: Remove backslash chars from values if they prepend '[' or ']'.
859**/
860
861List getCIKeywordsFromCommitMsg() {
862 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
863 List commitMsgLines = commitMsg.split('\n')
864 List keywords = []
865 if (commitMsgLines.size() < 2) {
866 return keywords
867 }
868
869 String commitMsgBody = commitMsgLines[1..-1].join('\n')
870
871 // Split commit message body to chunks using '[' or ']' as delimiter,
872 // ignoring them if prepended by backslash (regex negative lookbehind).
873 // Resulting list will have chunks between '[' and ']' at odd indexes.
874 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
875
876 // Iterate chunks by odd indexes only, trim values and split to
877 // <key> / <value> pair where <key> is the part of a sting before the first
878 // whitespace delimiter, and <value> is the rest (may include whitespaces).
879 // If there is no whitespace in the string then this is a 'switch'
880 // and <value> will be boolean True.
881 for (i = 1; i < parts.size(); i += 2) {
882 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
883 keywords.add(['key': key, 'value': value])
884 }
885
886 return keywords
887}
888
889/**
890* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
891* that were specified for given job name. `job-params` keyword has the following structure
892*
893* [job-params <job name> <parameter name> <parameter value>]
894*
895* Return value is a Map that contains those parameters using the following structure:
896*
897* <job name>:
898* <parameter name>: <parameter value>
899*
900**/
901Map getJobsParamsFromCommitMsg() {
902 List keywords = getCIKeywordsFromCommitMsg()
903
904 List jobsParamsList = []
905 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
906 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
907 def (key, value) = params.split(/\s+/, 2)
908 ['name': name, 'key': key, 'value': value]
909 }
910
911 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
912 if (!result.containsKey(it.name)) {
913 result[it.name] = [:]
914 }
915 result[it.name][it.key] = it.value
916 result
917 }
918
919 return jobsParams
920}
921
922
923/**
924* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
925* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
926* uses only those parametes that were set to all jobs (with <job name> == '*') or to
927* a particular job. Parameters set to a particular job have higher precedence.
928*
929* Return value is a Map that contains those parameters:
930*
931* <parameter name>: <parameter value>
932*
933**/
934Map getJobParamsFromCommitMsg(String jobName) {
935 jobsParams = getJobsParamsFromCommitMsg()
936 jobParams = jobsParams.getOrDefault('*', [:])
937 if (jobName) {
938 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
939 }
940 return jobParams
941}