blob: e2ce9e4af763829c5a6df12cbf3cee49d675b710 [file] [log] [blame]
Ales Komarek1fe5b8f2017-03-06 11:07:54 +01001/**
2 * Update packages pipeline script
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API (str)
6 * SALT_MASTER_URL URL of Salt-API (str)
7 *
8 * UPDATE_SERVERS Salt target for updated servers (str)
9 * UPDATE_COMMIT Confirm update should be performed (boot)
10 * UPDATE_PACKAGES List of packages to update
11 *
12**/
13
14
15
16def common = new com.mirantis.mk.Common()
17def salt = new com.mirantis.mk.Salt()
18timestamps {
19 node() {
20 try {
21
22 stage("Connect to Salt master") {
23 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
24 }
25
26 stage("Get package versions") {
27 salt.runSaltProcessStep(saltMaster, UPDATE_SERVERS, 'pkg.list_upgrades', [], null, true)
28 }
29
Tomáš Kukrál1ece6c82017-03-06 15:16:47 +010030 if (UPDATE_COMMIT.toBoolean() == true) {
Ales Komarek1fe5b8f2017-03-06 11:07:54 +010031 stage("Update packages") {
32 if (UPDATE_PACKAGES == "") {
33 salt.runSaltProcessStep(saltMaster, UPDATE_SERVERS, 'pkg.install', [], null, true)
Tomáš Kukrál1ece6c82017-03-06 15:16:47 +010034 } else {
Ales Komarek1fe5b8f2017-03-06 11:07:54 +010035 salt.runSaltProcessStep(saltMaster, UPDATE_SERVERS, 'pkg.install', UPDATE_PACKAGES.split(' '), null, true)
36 }
37 }
38 }
39
40 } catch (Throwable e) {
41 // If there was an error or exception thrown, the build failed
42 currentBuild.result = "FAILURE"
43 throw e
44 } finally {
45 // common.sendNotification(currentBuild.result,"",["slack"])
46 }
47 }
48}