blob: 5bc0ab20ace86a0b3294a9e880080523cecca2b4 [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
azvyagintsevf3bf77a2018-11-15 19:30:04 +020092if (common.validInputParam('PIPELINE_TIMEOUT') && env.PIPELINE_TIMEOUT.isInteger()) {
93 pipelineTimeout = env.PIPELINE_TIMEOUT.toInteger()
Martin Polreich965c9032018-08-09 16:33:57 +020094}
95
96timeout(time: pipelineTimeout, unit: 'HOURS') {
Jakub Josefa63f9862018-01-11 17:58:38 +010097 node("python") {
98 try {
Richard Felkl0e80d892018-06-20 13:44:54 +020099 workspace = common.getWorkspace()
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200100 targetMcpVersion = null
101 if (!common.validInputParam('TARGET_MCP_VERSION') && !common.validInputParam('MCP_VERSION')) {
102 error('You must specify MCP version in TARGET_MCP_VERSION|MCP_VERSION variable')
azvyagintsev6dac3802018-11-09 15:11:30 +0200103 }
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200104 // bw comp. for 2018.X => 2018.11 release
105 if (common.validInputParam('MCP_VERSION')){
106 targetMcpVersion = env.MCP_VERSION
107 common.warningMsg("targetMcpVersion has been changed to:${targetMcpVersion}, which was taken from deprecated pipeline viriable:MCP_VERSION")
108 }
109 else {
110 targetMcpVersion = env.TARGET_MCP_VERSION
111 }
112 // end bw comp. for 2018.X => 2018.11 release
Denis Egorenkod13ad132018-12-17 16:56:02 +0400113 def gitTargetMcpVersion = env.getProperty('GIT_REFSPEC')
Denis Egorenko284690e2018-12-25 15:55:12 +0400114 if (targetMcpVersion in ['testing', 'proposed']) {
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200115 gitTargetMcpVersion = 'master'
116 common.warningMsg("gitTargetMcpVersion has been changed to:${gitTargetMcpVersion}")
Denis Egorenko284690e2018-12-25 15:55:12 +0400117 } else if (!gitTargetMcpVersion) {
118 // backward compatibility for 2018.11.0
119 gitTargetMcpVersion = "release/${targetMcpVersion}"
azvyagintsev6dac3802018-11-09 15:11:30 +0200120 }
Denis Egorenko284690e2018-12-25 15:55:12 +0400121 def saltMastURL = ''
122 def saltMastCreds = ''
123 def upgradeSaltStack = ''
124 def updateClusterModel = ''
125 def updatePipelines = ''
126 def updateLocalRepos = ''
127 def reclassSystemBranch = ''
Denis Egorenkod13ad132018-12-17 16:56:02 +0400128 def driteTrainParamsYaml = env.getProperty('DRIVE_TRAIN_PARAMS')
Denis Egorenko284690e2018-12-25 15:55:12 +0400129 if (driteTrainParamsYaml) {
130 def driteTrainParams = readYaml text: driteTrainParamsYaml
131 saltMastURL = driteTrainParams.get('SALT_MASTER_URL')
132 defsaltMastCreds = driteTrainParams.get('SALT_MASTER_CREDENTIALS')
133 upgradeSaltStack = driteTrainParams.get('UPGRADE_SALTSTACK', false).toBoolean()
134 updateClusterModel = driteTrainParams.get('UPDATE_CLUSTER_MODEL', false).toBoolean()
135 updatePipelines = driteTrainParams.get('UPDATE_PIPELINES', false).toBoolean()
136 updateLocalRepos = driteTrainParams.get('UPDATE_LOCAL_REPOS', false).toBoolean()
137 reclassSystemBranch = driteTrainParams.get('RECLASS_SYSTEM_BRANCH', gitTargetMcpVersion)
138 } else {
139 // backward compatibility for 2018.11.0
140 saltMastURL = env.getProperty('SALT_MASTER_URL')
141 saltMastCreds = env.getProperty('SALT_MASTER_CREDENTIALS')
142 upgradeSaltStack = env.getProperty('UPGRADE_SALTSTACK', false).toBoolean()
143 updateClusterModel = env.getProperty('UPDATE_CLUSTER_MODEL', false).toBoolean()
144 updatePipelines = env.getProperty('UPDATE_PIPELINES', false).toBoolean()
145 updateLocalRepos = env.getProperty('UPDATE_LOCAL_REPOS', false).toBoolean()
146 reclassSystemBranch = gitTargetMcpVersion
147 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100148
Denis Egorenkod13ad132018-12-17 16:56:02 +0400149 python.setupPepperVirtualenv(venvPepper, saltMastURL, saltMastCreds)
150
151 def inventoryBeforeFilename = "reclass-inventory-before.out"
152 def inventoryAfterFilename = "reclass-inventory-after.out"
153
154 def minions = salt.getMinions(venvPepper, '*')
155
156 stage("Update Reclass and Salt-Formulas ") {
157 validateReclassModel(minions, 'before')
158
Richard Felkl970e0082018-06-12 18:00:51 +0200159 def cluster_name = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0]
azvyagintsev6dac3802018-11-09 15:11:30 +0200160 try {
Sergey382581a2018-10-25 12:22:26 +0400161 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/ && git diff-index --quiet HEAD --")
Richard Felkl970e0082018-06-12 18:00:51 +0200162 }
azvyagintsev6dac3802018-11-09 15:11:30 +0200163 catch (Exception ex) {
Sergey382581a2018-10-25 12:22:26 +0400164 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 +0200165 }
Denis Egorenkod13ad132018-12-17 16:56:02 +0400166 if (updateClusterModel) {
azvyagintsev6dac3802018-11-09 15:11:30 +0200167 common.infoMsg('Perform: UPDATE_CLUSTER_MODEL')
Sergey382581a2018-10-25 12:22:26 +0400168 def dateTime = common.getDatetime()
169 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " +
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200170 "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 +0200171 // Do the same, for deprecated variable-duplicate
172 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " +
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200173 "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 +0400174 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && " +
175 "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 +0400176 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/system && git checkout ${reclassSystemBranch}")
Sergey382581a2018-10-25 12:22:26 +0400177 // Add new defaults
178 common.infoMsg("Add new defaults")
Denis Egorenkod13ad132018-12-17 16:56:02 +0400179 salt.cmdRun(venvPepper, 'I@salt:master', "grep '^ mcp_version: ' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml || " +
180 "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 +0400181 salt.cmdRun(venvPepper, 'I@salt:master', "grep '^- system.defaults\$' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml || " +
azvyagintsev6dac3802018-11-09 15:11:30 +0200182 "sed -i 's/^classes:/classes:\\n- system.defaults/' /srv/salt/reclass/classes/cluster/$cluster_name/infra/init.yml")
Sergey382581a2018-10-25 12:22:26 +0400183 common.infoMsg("The following changes were made to the cluster model and will be commited. " +
azvyagintsev6dac3802018-11-09 15:11:30 +0200184 "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 +0400185 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && git diff")
186 salt.cmdRun(venvPepper, 'I@salt:master', "cd /srv/salt/reclass/classes/cluster/$cluster_name && git status && " +
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200187 "git add -u && git commit --allow-empty -m 'Cluster model update to the release $targetMcpVersion on $dateTime'")
Sergey382581a2018-10-25 12:22:26 +0400188 }
Denis Egorenkod13ad132018-12-17 16:56:02 +0400189
190 try {
191 common.infoMsg('Perform: UPDATE Salt Formulas')
192 salt.enforceState(venvPepper, 'I@salt:master', 'linux.system.repo')
193 def saltEnv = salt.getPillar(venvPepper, 'I@salt:master', "_param:salt_master_base_environment").get("return")[0].values()[0]
194 salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'state.sls_id', ["salt_master_${saltEnv}_pkg_formulas",'salt.master.env'])
195 } catch (Exception updateErr) {
196 common.warningMsg(updateErr)
197 common.warningMsg('Failed to update Salt Formulas repos/packages. Check current available documentation on https://docs.mirantis.com/mcp/latest/, how to update packages.')
198 input message: 'Continue anyway?'
199 }
200
201 archiveReclassInventory(inventoryBeforeFilename)
202
203 try {
204 common.infoMsg('Perform: UPDATE Reclass package')
205 salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'pkg.install', ["reclass"])
206 } catch (Exception updateErr) {
207 common.warningMsg(updateErr)
208 common.warningMsg('Failed to update Reclass package. Check current available documentation on https://docs.mirantis.com/mcp/latest/, how to update packages.')
209 input message: 'Continue anyway?'
210 }
211
212 salt.fullRefresh(venvPepper, 'I@salt:master')
Sergey1b81c062018-10-16 17:10:21 +0400213 salt.enforceState(venvPepper, 'I@salt:master', 'reclass.storage', true)
Denis Egorenkod13ad132018-12-17 16:56:02 +0400214 try {
215 salt.enforceState(venvPepper, "I@salt:master", 'reclass', true)
216 }
217 catch (Exception ex) {
218 error("Reclass fails rendering. Pay attention to your cluster model.")
219 }
220
221 salt.fullRefresh(venvPepper, '*')
222
223 try {
224 salt.cmdRun(venvPepper, 'I@salt:master', "reclass-salt --top")
225 }
226 catch (Exception ex) {
227 error("Reclass fails rendering. Pay attention to your cluster model.")
228 }
229
230 archiveReclassInventory(inventoryAfterFilename)
231
232 sh "diff -u $inventoryBeforeFilename $inventoryAfterFilename > reclass-inventory-diff.out || true"
233 archiveArtifacts artifacts: "reclass-inventory-diff.out"
234
235 validateReclassModel(minions, 'after')
236 archiveReclassModelChanges(minions)
Jakub Josefa63f9862018-01-11 17:58:38 +0100237 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100238
Denis Egorenkod13ad132018-12-17 16:56:02 +0400239 if (updateLocalRepos) {
Sergey1b81c062018-10-16 17:10:21 +0400240 def cluster_name = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0]
azvyagintsev6dac3802018-11-09 15:11:30 +0200241 stage("Update local repos") {
Jakub Josefa63f9862018-01-11 17:58:38 +0100242 common.infoMsg("Updating local repositories")
Sam Stoelingaaab79702018-04-09 18:49:39 -0700243
Sergey1b81c062018-10-16 17:10:21 +0400244 def engine = salt.getPillar(venvPepper, 'I@aptly:publisher', "aptly:publisher:source:engine")
Sam Stoelingaaab79702018-04-09 18:49:39 -0700245 runningOnDocker = engine.get("return")[0].containsValue("docker")
246
247 if (runningOnDocker) {
248 common.infoMsg("Aptly is running as Docker container")
azvyagintsev6dac3802018-11-09 15:11:30 +0200249 } else {
Sam Stoelingaaab79702018-04-09 18:49:39 -0700250 common.infoMsg("Aptly isn't running as Docker container. Going to use aptly user for executing aptly commands")
251 }
252
azvyagintsev6dac3802018-11-09 15:11:30 +0200253 if (runningOnDocker) {
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200254 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 +0200255 } else {
azvyagintsevf3bf77a2018-11-15 19:30:04 +0200256 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 +0100257 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100258
Sergey1b81c062018-10-16 17:10:21 +0400259 salt.enforceState(venvPepper, 'I@aptly:publisher', 'aptly', true)
Richard Felkl26cae4d2017-12-19 00:19:16 +0100260
azvyagintsev6dac3802018-11-09 15:11:30 +0200261 if (runningOnDocker) {
Sergey1b81c062018-10-16 17:10:21 +0400262 salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_mirror_update.sh', "args=-sv"], null, true)
263 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 +0200264 } else {
Sergey1b81c062018-10-16 17:10:21 +0400265 salt.runSaltProcessStep(venvPepper, 'I@aptly:publisher', 'cmd.script', ['salt://aptly/files/aptly_mirror_update.sh', "args=-sv", 'runas=aptly'], null, true)
266 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 +0100267 }
Richard Felkl79d7df12018-01-05 16:40:11 +0100268
Sergey1b81c062018-10-16 17:10:21 +0400269 salt.enforceState(venvPepper, 'I@aptly:publisher', 'docker.client.registry', true)
Richard Felkl26cae4d2017-12-19 00:19:16 +0100270
Sergey1b81c062018-10-16 17:10:21 +0400271 salt.enforceState(venvPepper, 'I@aptly:publisher', 'debmirror', true)
Richard Felkl26cae4d2017-12-19 00:19:16 +0100272
Sergey1b81c062018-10-16 17:10:21 +0400273 salt.enforceState(venvPepper, 'I@aptly:publisher', 'git.server', true)
Richard Felkl5f7fdaf2018-02-15 15:38:31 +0100274
Sergey1b81c062018-10-16 17:10:21 +0400275 salt.enforceState(venvPepper, 'I@aptly:publisher', 'linux.system.file', true)
Jakub Josefa63f9862018-01-11 17:58:38 +0100276 }
277 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100278
azvyagintsev6dac3802018-11-09 15:11:30 +0200279 stage("Update Drivetrain") {
Denis Egorenkod13ad132018-12-17 16:56:02 +0400280 if (upgradeSaltStack) {
281 updateSaltStack("I@salt:master", '["salt-master", "salt-common", "salt-api", "salt-minion"]')
Richard Felkl0e80d892018-06-20 13:44:54 +0200282
Richard Felkl0e80d892018-06-20 13:44:54 +0200283 salt.enforceState(venvPepper, "I@linux:system", 'linux.system.repo', true)
Richard Felkl0e80d892018-06-20 13:44:54 +0200284 updateSaltStack("I@salt:minion and not I@salt:master", '["salt-minion"]')
285 }
286
Denis Egorenkod13ad132018-12-17 16:56:02 +0400287 if (updatePipelines) {
Richard Felkl970e0082018-06-12 18:00:51 +0200288 triggerMirrorJob("git-mirror-downstream-mk-pipelines")
289 triggerMirrorJob("git-mirror-downstream-pipeline-library")
290 }
291
292 salt.enforceState(venvPepper, "I@jenkins:client", 'jenkins.client', true)
293
294 salt.cmdRun(venvPepper, "I@salt:master", "salt -C 'I@jenkins:client and I@docker:client' state.sls docker.client --async")
295
296 sleep(180)
297
298 common.infoMsg("Checking if Docker containers are up")
299
azvyagintsev6dac3802018-11-09 15:11:30 +0200300 try {
301 common.retry(10, 30) {
Richard Felkl970e0082018-06-12 18:00:51 +0200302 salt.cmdRun(venvPepper, 'I@jenkins:client and I@docker:client', "! docker service ls | tail -n +2 | grep -v -E '\\s([0-9])/\\1\\s'")
303 }
304 }
azvyagintsev6dac3802018-11-09 15:11:30 +0200305 catch (Exception ex) {
Richard Felkl970e0082018-06-12 18:00:51 +0200306 error("Docker containers for CI/CD services are having troubles with starting.")
307 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100308 }
309 }
Jakub Josefa63f9862018-01-11 17:58:38 +0100310 catch (Throwable e) {
311 // If there was an error or exception thrown, the build failed
312 currentBuild.result = "FAILURE"
313 throw e
Richard Felkl26cae4d2017-12-19 00:19:16 +0100314 }
Richard Felkl26cae4d2017-12-19 00:19:16 +0100315 }
Jakub Josef2c21c6c2018-02-08 18:51:42 +0100316}