blob: efea4a0cda2c3afa097c809c1974677c16f34650 [file] [log] [blame]
Richard Felkl26cae4d2017-12-19 00:19:16 +01001/**
2 *
3 * Update Salt environment pipeline
4 *
5 * Expected parameters:
azvyagintsev6dac3802018-11-09 15:11:30 +02006 * TARGET_MCP_VERSION Version of MCP to upgrade to
Denis Egorenkod13ad132018-12-17 16:56:02 +04007 * GIT_REFSPEC Git repo ref to be used
8 * DRIVE_TRAIN_PARAMS Yaml, DriveTrain releated params:
9 * SALT_MASTER_URL Salt API server location
10 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
11 * UPGRADE_SALTSTACK Upgrade SaltStack packages to new version.
12 * UPDATE_CLUSTER_MODEL Update MCP version parameter in cluster model
13 * UPDATE_PIPELINES Update pipeline repositories on Gerrit
14 * UPDATE_LOCAL_REPOS Update local repositories
Richard Felkl26cae4d2017-12-19 00:19:16 +010015 */
16
Richard Felkl5f7fdaf2018-02-15 15:38:31 +010017salt = new com.mirantis.mk.Salt()
18common = new com.mirantis.mk.Common()
19python = new com.mirantis.mk.Python()
Richard Felkl970e0082018-06-12 18:00:51 +020020jenkinsUtils = new com.mirantis.mk.JenkinsUtils()
azvyagintsevf3bf77a2018-11-15 19:30:04 +020021def pipelineTimeout = 12
Richard Felkl5f7fdaf2018-02-15 15:38:31 +010022venvPepper = "venvPepper"
Richard Felkl0e80d892018-06-20 13:44:54 +020023workspace = ""
Richard Felkl5f7fdaf2018-02-15 15:38:31 +010024
azvyagintsev6dac3802018-11-09 15:11:30 +020025def triggerMirrorJob(jobName) {
Richard Felkl970e0082018-06-12 18:00:51 +020026 params = jenkinsUtils.getJobParameters(jobName)
27 build job: jobName, parameters: [
28 [$class: 'StringParameterValue', name: 'BRANCHES', value: params.get("BRANCHES")],
29 [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: params.get("CREDENTIALS_ID")],
30 [$class: 'StringParameterValue', name: 'SOURCE_URL', value: params.get("SOURCE_URL")],
31 [$class: 'StringParameterValue', name: 'TARGET_URL', value: params.get("TARGET_URL")]
32 ]
33}
34
azvyagintsev6dac3802018-11-09 15:11:30 +020035def updateSaltStack(target, pkgs) {
Denis Egorenkod13ad132018-12-17 16:56:02 +040036 // wait 2 mins when salt-* packages are updated which leads to salt-* services restart
37 common.retry(2, 120) {
Richard Felkl0e80d892018-06-20 13:44:54 +020038 salt.runSaltProcessStep(venvPepper, target, 'pkg.install', ["force_yes=True", "pkgs='$pkgs'"], null, true, 5)
azvyagintsev6dac3802018-11-09 15:11:30 +020039 }
Richard Felkl0e80d892018-06-20 13:44:54 +020040
azvyagintsev6dac3802018-11-09 15:11:30 +020041 common.retry(20, 60) {
Richard Felkl0e80d892018-06-20 13:44:54 +020042 salt.minionsReachable(venvPepper, 'I@salt:master', '*')
43 def running = salt.runSaltProcessStep(venvPepper, target, 'saltutil.running', [], null, true, 5)
azvyagintsev6dac3802018-11-09 15:11:30 +020044 for (value in running.get("return")[0].values()) {
45 if (value != []) {
Richard Felkl0e80d892018-06-20 13:44:54 +020046 throw new Exception("Not all salt-minions are ready for execution")
47 }
48 }
49 }
50
azvyagintsevf3bf77a2018-11-15 19:30:04 +020051 def saltVersion = salt.getPillar(venvPepper, 'I@salt:master', '_param:salt_version').get('return')[0].values()[0]
Richard Felklf23257e2018-08-06 09:24:23 +020052 def saltMinionVersions = salt.cmdRun(venvPepper, target, "apt-cache policy salt-common | awk '/Installed/ && /$saltVersion/'").get("return")
Richard Felkl0e80d892018-06-20 13:44:54 +020053 def saltMinionVersion = ""
54
azvyagintsev6dac3802018-11-09 15:11:30 +020055 for (minion in saltMinionVersions[0].keySet()) {
56 saltMinionVersion = saltMinionVersions[0].get(minion).replace("Salt command execution success", "").trim()
57 if (saltMinionVersion == "") {
Richard Felkl0e80d892018-06-20 13:44:54 +020058 error("Installed version of Salt on $minion doesn't match specified version in the model.")
59 }
60 }
61}
62
azvyagintsev6dac3802018-11-09 15:11:30 +020063def archiveReclassInventory(filename) {
Richard Felkl0e80d892018-06-20 13:44:54 +020064 def ret = salt.cmdRun(venvPepper, 'I@salt:master', "reclass -i", true, null, false)
65 def reclassInv = ret.values()[0]
66 writeFile file: filename, text: reclassInv.toString()
67 archiveArtifacts artifacts: "$filename"
68}
69
Denis Egorenkod13ad132018-12-17 16:56:02 +040070def validateReclassModel(ArrayList saltMinions, String suffix) {
71 try {
72 for(String minion in saltMinions) {
73 common.infoMsg("Reclass model validation for minion ${minion}...")
74 def ret = salt.cmdRun(venvPepper, 'I@salt:master', "reclass -n ${minion}", true, null, false)
75 def reclassInv = ret.values()[0]
76 writeFile file: "inventory-${minion}-${suffix}.out", text: reclassInv.toString()
77 }
78 } catch (Exception e) {
79 common.errorMsg('Can not validate current Reclass model. Inspect failed minion manually.')
80 error(e)
81 }
82}
83
84def archiveReclassModelChanges(ArrayList saltMinions, String oldSuffix='before', String newSuffix='after') {
85 for(String minion in saltMinions) {
86 def fileName = "reclass-model-${minion}-diff.out"
87 sh "diff -u inventory-${minion}-${oldSuffix}.out inventory-${minion}-${newSuffix}.out > ${fileName} || true"
88 archiveArtifacts artifacts: "${fileName}"
89 }
90}
91
Denis Egorenko5a8a7e92018-12-27 14:13:48 +040092if (common.validInputParam('PIPELINE_TIMEOUT')) {
93 try {
94 pipelineTimeout = env.PIPELINE_TIMEOUT.toInteger()
95 } catch(Exception e) {
96 common.warningMsg("Provided PIPELINE_TIMEOUT parameter has invalid value: ${env.PIPELINE_TIMEOUT} - should be interger")
97 }
Martin Polreich965c9032018-08-09 16:33:57 +020098}
99
100timeout(time: pipelineTimeout, unit: 'HOURS') {
Jakub Josefa63f9862018-01-11 17:58:38 +0100101 node("python") {
102 try {
Richard Felkl0e80d892018-06-20 13:44:54 +0200103 workspace = common.getWorkspace()
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200104 targetMcpVersion = null
105 if (!common.validInputParam('TARGET_MCP_VERSION') && !common.validInputParam('MCP_VERSION')) {
106 error('You must specify MCP version in TARGET_MCP_VERSION|MCP_VERSION variable')
azvyagintsev6dac3802018-11-09 15:11:30 +0200107 }
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200108 // bw comp. for 2018.X => 2018.11 release
109 if (common.validInputParam('MCP_VERSION')){
110 targetMcpVersion = env.MCP_VERSION
111 common.warningMsg("targetMcpVersion has been changed to:${targetMcpVersion}, which was taken from deprecated pipeline viriable:MCP_VERSION")
112 }
113 else {
114 targetMcpVersion = env.TARGET_MCP_VERSION
115 }
116 // end bw comp. for 2018.X => 2018.11 release
Denis Egorenkod13ad132018-12-17 16:56:02 +0400117 def gitTargetMcpVersion = env.getProperty('GIT_REFSPEC')
Denis Egorenko284690e2018-12-25 15:55:12 +0400118 if (targetMcpVersion in ['testing', 'proposed']) {
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200119 gitTargetMcpVersion = 'master'
120 common.warningMsg("gitTargetMcpVersion has been changed to:${gitTargetMcpVersion}")
Denis Egorenko284690e2018-12-25 15:55:12 +0400121 } else if (!gitTargetMcpVersion) {
122 // backward compatibility for 2018.11.0
123 gitTargetMcpVersion = "release/${targetMcpVersion}"
azvyagintsev6dac3802018-11-09 15:11:30 +0200124 }
Denis Egorenko284690e2018-12-25 15:55:12 +0400125 def saltMastURL = ''
126 def saltMastCreds = ''
127 def upgradeSaltStack = ''
128 def updateClusterModel = ''
129 def updatePipelines = ''
130 def updateLocalRepos = ''
131 def reclassSystemBranch = ''
Denis Egorenkod13ad132018-12-17 16:56:02 +0400132 def driteTrainParamsYaml = env.getProperty('DRIVE_TRAIN_PARAMS')
Denis Egorenko284690e2018-12-25 15:55:12 +0400133 if (driteTrainParamsYaml) {
134 def driteTrainParams = readYaml text: driteTrainParamsYaml
135 saltMastURL = driteTrainParams.get('SALT_MASTER_URL')
Denis Egorenko928b3e82019-01-15 11:47:16 +0400136 saltMastCreds = driteTrainParams.get('SALT_MASTER_CREDENTIALS')
Denis Egorenko284690e2018-12-25 15:55:12 +0400137 upgradeSaltStack = driteTrainParams.get('UPGRADE_SALTSTACK', false).toBoolean()
138 updateClusterModel = driteTrainParams.get('UPDATE_CLUSTER_MODEL', false).toBoolean()
139 updatePipelines = driteTrainParams.get('UPDATE_PIPELINES', false).toBoolean()
140 updateLocalRepos = driteTrainParams.get('UPDATE_LOCAL_REPOS', false).toBoolean()
141 reclassSystemBranch = driteTrainParams.get('RECLASS_SYSTEM_BRANCH', gitTargetMcpVersion)
142 } else {
143 // backward compatibility for 2018.11.0
144 saltMastURL = env.getProperty('SALT_MASTER_URL')
145 saltMastCreds = env.getProperty('SALT_MASTER_CREDENTIALS')
Denis Egorenkoe5f39142018-12-28 12:30:48 +0400146 upgradeSaltStack = env.getProperty('UPGRADE_SALTSTACK').toBoolean()
147 updateClusterModel = env.getProperty('UPDATE_CLUSTER_MODEL').toBoolean()
148 updatePipelines = env.getProperty('UPDATE_PIPELINES').toBoolean()
149 updateLocalRepos = env.getProperty('UPDATE_LOCAL_REPOS').toBoolean()
Denis Egorenko284690e2018-12-25 15:55:12 +0400150 reclassSystemBranch = gitTargetMcpVersion
151 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100152
Denis Egorenkod13ad132018-12-17 16:56:02 +0400153 python.setupPepperVirtualenv(venvPepper, saltMastURL, saltMastCreds)
154
155 def inventoryBeforeFilename = "reclass-inventory-before.out"
156 def inventoryAfterFilename = "reclass-inventory-after.out"
157
158 def minions = salt.getMinions(venvPepper, '*')
159
160 stage("Update Reclass and Salt-Formulas ") {
161 validateReclassModel(minions, 'before')
162
Richard Felkl970e0082018-06-12 18:00:51 +0200163 def cluster_name = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0]
azvyagintsev6dac3802018-11-09 15:11:30 +0200164 try {
Sergey382581a2018-10-25 12:22:26 +0400165 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/ && git diff-index --quiet HEAD --")
Richard Felkl970e0082018-06-12 18:00:51 +0200166 }
azvyagintsev6dac3802018-11-09 15:11:30 +0200167 catch (Exception ex) {
Sergey382581a2018-10-25 12:22:26 +0400168 error("You have uncommited changes in your Reclass cluster model repository. Please commit or reset them and rerun the pipeline.")
Richard Felkl970e0082018-06-12 18:00:51 +0200169 }
Denis Egorenkod13ad132018-12-17 16:56:02 +0400170 if (updateClusterModel) {
azvyagintsev6dac3802018-11-09 15:11:30 +0200171 common.infoMsg('Perform: UPDATE_CLUSTER_MODEL')
Sergey382581a2018-10-25 12:22:26 +0400172 def dateTime = common.getDatetime()
173 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " +
Denis Egorenko928b3e82019-01-15 11:47:16 +0400174 "grep -r --exclude-dir=aptly -l 'mcp_version: .*' * | xargs --no-run-if-empty sed -i 's|mcp_version: .*|mcp_version: \"$targetMcpVersion\"|g'")
azvyagintsev6dac3802018-11-09 15:11:30 +0200175 // Do the same, for deprecated variable-duplicate
176 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " +
Denis Egorenko928b3e82019-01-15 11:47:16 +0400177 "grep -r --exclude-dir=aptly -l 'apt_mk_version: .*' * | xargs --no-run-if-empty sed -i 's|apt_mk_version: .*|apt_mk_version: \"$targetMcpVersion\"|g'")
Denis Egorenko284690e2018-12-25 15:55:12 +0400178 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " +
Denis Egorenko928b3e82019-01-15 11:47:16 +0400179 "grep -r --exclude-dir=aptly -l 'jenkins_pipelines_branch: .*' * | xargs --no-run-if-empty sed -i 's|jenkins_pipelines_branch: .*|jenkins_pipelines_branch: \"$gitTargetMcpVersion\"|g'")
Denis Egorenkod13ad132018-12-17 16:56:02 +0400180 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/system && git checkout ${reclassSystemBranch}")
Sergey382581a2018-10-25 12:22:26 +0400181 // Add new defaults
182 common.infoMsg("Add new defaults")
Denis Egorenkod13ad132018-12-17 16:56:02 +0400183 salt.cmdRun(venvPepper, 'I@salt:master', "grep '^ mcp_version: ' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml || " +
Denis Egorenko928b3e82019-01-15 11:47:16 +0400184 "sed -i 's|^ _param:| _param:\\n mcp_version: \"$targetMcpVersion\"|' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml")
Sergey382581a2018-10-25 12:22:26 +0400185 salt.cmdRun(venvPepper, 'I@salt:master', "grep '^- system.defaults\$' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml || " +
Denis Egorenko928b3e82019-01-15 11:47:16 +0400186 "sed -i 's|^classes:|classes:\\n- system.defaults|' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml")
Sergey382581a2018-10-25 12:22:26 +0400187 common.infoMsg("The following changes were made to the cluster model and will be commited. " +
azvyagintsev6dac3802018-11-09 15:11:30 +0200188 "Please consider if you want to push them to the remote repository or not. You have to do this manually when the run is finished.")
Sergey382581a2018-10-25 12:22:26 +0400189 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && git diff")
190 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && git status && " +
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200191 "git add -u && git commit --allow-empty -m 'Cluster model update to the release $targetMcpVersion on $dateTime'")
Sergey382581a2018-10-25 12:22:26 +0400192 }
Denis Egorenkod13ad132018-12-17 16:56:02 +0400193
194 try {
195 common.infoMsg('Perform: UPDATE Salt Formulas')
196 salt.enforceState(venvPepper, 'I@salt:master', 'linux.system.repo')
197 def saltEnv = salt.getPillar(venvPepper, 'I@salt:master', "_param:salt_master_base_environment").get("return")[0].values()[0]
198 salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'state.sls_id', ["salt_master_${saltEnv}_pkg_formulas",'salt.master.env'])
199 } catch (Exception updateErr) {
200 common.warningMsg(updateErr)
201 common.warningMsg('Failed to update Salt Formulas repos/packages. Check current available documentation on https://docs.mirantis.com/mcp/latest/, how to update packages.')
202 input message: 'Continue anyway?'
203 }
204
205 archiveReclassInventory(inventoryBeforeFilename)
206
207 try {
208 common.infoMsg('Perform: UPDATE Reclass package')
209 salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'pkg.install', ["reclass"])
210 } catch (Exception updateErr) {
211 common.warningMsg(updateErr)
212 common.warningMsg('Failed to update Reclass package. Check current available documentation on https://docs.mirantis.com/mcp/latest/, how to update packages.')
213 input message: 'Continue anyway?'
214 }
215
216 salt.fullRefresh(venvPepper, 'I@salt:master')
Sergey1b81c062018-10-16 17:10:21 +0400217 salt.enforceState(venvPepper, 'I@salt:master', 'reclass.storage', true)
Denis Egorenkod13ad132018-12-17 16:56:02 +0400218 try {
219 salt.enforceState(venvPepper, "I@salt:master", 'reclass', true)
220 }
221 catch (Exception ex) {
222 error("Reclass fails rendering. Pay attention to your cluster model.")
223 }
224
225 salt.fullRefresh(venvPepper, '*')
226
227 try {
228 salt.cmdRun(venvPepper, 'I@salt:master', "reclass-salt --top")
229 }
230 catch (Exception ex) {
231 error("Reclass fails rendering. Pay attention to your cluster model.")
232 }
233
234 archiveReclassInventory(inventoryAfterFilename)
235
236 sh "diff -u $inventoryBeforeFilename $inventoryAfterFilename > reclass-inventory-diff.out || true"
237 archiveArtifacts artifacts: "reclass-inventory-diff.out"
238
239 validateReclassModel(minions, 'after')
240 archiveReclassModelChanges(minions)
Jakub Josefa63f9862018-01-11 17:58:38 +0100241 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100242
Denis Egorenkod13ad132018-12-17 16:56:02 +0400243 if (updateLocalRepos) {
Sergey1b81c062018-10-16 17:10:21 +0400244 def cluster_name = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0]
azvyagintsev6dac3802018-11-09 15:11:30 +0200245 stage("Update local repos") {
Jakub Josefa63f9862018-01-11 17:58:38 +0100246 common.infoMsg("Updating local repositories")
Sam Stoelingaaab79702018-04-09 18:49:39 -0700247
Sergey1b81c062018-10-16 17:10:21 +0400248 def engine = salt.getPillar(venvPepper, 'I@aptly:publisher', "aptly:publisher:source:engine")
Sam Stoelingaaab79702018-04-09 18:49:39 -0700249 runningOnDocker = engine.get("return")[0].containsValue("docker")
250
251 if (runningOnDocker) {
252 common.infoMsg("Aptly is running as Docker container")
azvyagintsev6dac3802018-11-09 15:11:30 +0200253 } else {
Sam Stoelingaaab79702018-04-09 18:49:39 -0700254 common.infoMsg("Aptly isn't running as Docker container. Going to use aptly user for executing aptly commands")
255 }
256
azvyagintsev6dac3802018-11-09 15:11:30 +0200257 if (runningOnDocker) {
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200258 salt.cmdRun(venvPepper, 'I@aptly:publisher', "aptly mirror list --raw | grep -E '*' | xargs --no-run-if-empty -n 1 aptly mirror drop -force", true, null, true)
azvyagintsev6dac3802018-11-09 15:11:30 +0200259 } else {
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200260 salt.cmdRun(venvPepper, 'I@aptly:publisher', "aptly mirror list --raw | grep -E '*' | xargs --no-run-if-empty -n 1 aptly mirror drop -force", true, null, true, ['runas=aptly'])
Richard Felkl5f7fdaf2018-02-15 15:38:31 +0100261 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100262
Sergey1b81c062018-10-16 17:10:21 +0400263 salt.enforceState(venvPepper, 'I@aptly:publisher', 'aptly', true)
Richard Felkl26cae4d2017-12-19 00:19:16 +0100264
azvyagintsev6dac3802018-11-09 15:11:30 +0200265 if (runningOnDocker) {
Sergey1b81c062018-10-16 17:10:21 +0400266 salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_mirror_update.sh', "args=-sv"], null, true)
267 salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_publish_update.sh', "args=-frv -u http://10.99.0.1:8080"], null, true)
azvyagintsev6dac3802018-11-09 15:11:30 +0200268 } else {
Sergey1b81c062018-10-16 17:10:21 +0400269 salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_mirror_update.sh', "args=-sv", 'runas=aptly'], null, true)
270 salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_publish_update.sh', "args=-afrv", 'runas=aptly'], null, true)
Richard Felkl5f7fdaf2018-02-15 15:38:31 +0100271 }
Richard Felkl79d7df12018-01-05 16:40:11 +0100272
Sergey1b81c062018-10-16 17:10:21 +0400273 salt.enforceState(venvPepper, 'I@aptly:publisher', 'docker.client.registry', true)
Richard Felkl26cae4d2017-12-19 00:19:16 +0100274
Sergey1b81c062018-10-16 17:10:21 +0400275 salt.enforceState(venvPepper, 'I@aptly:publisher', 'debmirror', true)
Richard Felkl26cae4d2017-12-19 00:19:16 +0100276
Sergey1b81c062018-10-16 17:10:21 +0400277 salt.enforceState(venvPepper, 'I@aptly:publisher', 'git.server', true)
Richard Felkl5f7fdaf2018-02-15 15:38:31 +0100278
Sergey1b81c062018-10-16 17:10:21 +0400279 salt.enforceState(venvPepper, 'I@aptly:publisher', 'linux.system.file', true)
Jakub Josefa63f9862018-01-11 17:58:38 +0100280 }
281 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100282
azvyagintsev6dac3802018-11-09 15:11:30 +0200283 stage("Update Drivetrain") {
Denis Egorenkod13ad132018-12-17 16:56:02 +0400284 if (upgradeSaltStack) {
285 updateSaltStack("I@salt:master", '["salt-master", "salt-common", "salt-api", "salt-minion"]')
Richard Felkl0e80d892018-06-20 13:44:54 +0200286
Richard Felkl0e80d892018-06-20 13:44:54 +0200287 salt.enforceState(venvPepper, "I@linux:system", 'linux.system.repo', true)
Richard Felkl0e80d892018-06-20 13:44:54 +0200288 updateSaltStack("I@salt:minion and not I@salt:master", '["salt-minion"]')
289 }
290
Denis Egorenkod13ad132018-12-17 16:56:02 +0400291 if (updatePipelines) {
Richard Felkl970e0082018-06-12 18:00:51 +0200292 triggerMirrorJob("git-mirror-downstream-mk-pipelines")
293 triggerMirrorJob("git-mirror-downstream-pipeline-library")
294 }
295
Denis Egorenkoaeaa1de2019-01-15 11:58:12 +0400296 // updating users and keys
297 salt.enforceState(venvPepper, "I@linux:system", 'linux.system.user', true)
298 salt.enforceState(venvPepper, "I@linux:system", 'openssh', true)
299
Richard Felkl970e0082018-06-12 18:00:51 +0200300 salt.enforceState(venvPepper, "I@jenkins:client", 'jenkins.client', true)
301
302 salt.cmdRun(venvPepper, "I@salt:master", "salt -C 'I@jenkins:client and I@docker:client' state.sls docker.client --async")
303
304 sleep(180)
305
306 common.infoMsg("Checking if Docker containers are up")
307
azvyagintsev6dac3802018-11-09 15:11:30 +0200308 try {
309 common.retry(10, 30) {
Richard Felkl970e0082018-06-12 18:00:51 +0200310 salt.cmdRun(venvPepper, 'I@jenkins:client and I@docker:client', "! docker service ls | tail -n +2 | grep -v -E '\\s([0-9])/\\1\\s'")
311 }
312 }
azvyagintsev6dac3802018-11-09 15:11:30 +0200313 catch (Exception ex) {
Richard Felkl970e0082018-06-12 18:00:51 +0200314 error("Docker containers for CI/CD services are having troubles with starting.")
315 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100316 }
317 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100318 catch (Throwable e) {
319 // If there was an error or exception thrown, the build failed
320 currentBuild.result = "FAILURE"
321 throw e
Richard Felkl26cae4d2017-12-19 00:19:16 +0100322 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100323 }
Jakub Josef2c21c6c2018-02-08 18:51:42 +0100324}