blob: 2ae408f32dcd76e7007188fa11c0e1fafb801f28 [file] [log] [blame]
Richard Felkl0eb0f602017-10-11 08:37:54 +02001/**
2 *
3 * Update Salt environment pipeline
4 *
5 * Expected parameters:
6 * SALT_MASTER_URL Salt API server location
7 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
8 * UPDATE_FORMULAS Boolean switch for enforcing updating formulas
9 */
10
11// Load shared libs
12def salt = new com.mirantis.mk.Salt()
13def common = new com.mirantis.mk.Common()
14def python = new com.mirantis.mk.Python()
15def venvPepper = "venvPepper"
Jakub Josefa63f9862018-01-11 17:58:38 +010016timeout(time: 12, unit: 'HOURS') {
17 node() {
18 try {
19 python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
Richard Felkl0eb0f602017-10-11 08:37:54 +020020
Jakub Josefa63f9862018-01-11 17:58:38 +010021 stage("Update formulas"){
22 if(UPDATE_FORMULAS.toBoolean()){
23 common.infoMsg("Updating salt formulas")
24 salt.cmdRun(
25 venvPepper,
26 "I@salt:master",
27 'apt-get update && apt-get install -y salt-formula-*'
28 )
29 common.infoMsg("Running salt sync-all")
Denis Egorenkoe983d452019-08-23 14:29:34 +040030 salt.runSaltProcessStep(venvPepper, '*', 'saltutil.sync_all', [], null, true)
Jakub Josefa63f9862018-01-11 17:58:38 +010031 }
32 }
33 stage("Update Reclass") {
34 common.infoMsg("Updating reclass model")
Richard Felkl0eb0f602017-10-11 08:37:54 +020035 salt.cmdRun(
36 venvPepper,
37 "I@salt:master",
Jakub Josefa63f9862018-01-11 17:58:38 +010038 'cd /srv/salt/reclass && git pull -r && git submodule update',
39 false
Richard Felkl0eb0f602017-10-11 08:37:54 +020040 )
Richard Felkl0eb0f602017-10-11 08:37:54 +020041
Jakub Josefa63f9862018-01-11 17:58:38 +010042 salt.enforceState(
43 venvPepper,
44 "I@salt:master",
45 'reclass',
46 true
47 )
48 }
49 } catch (Throwable e) {
50 // If there was an error or exception thrown, the build failed
51 currentBuild.result = "FAILURE"
52 throw e
Richard Felkl0eb0f602017-10-11 08:37:54 +020053 }
Richard Felkl0eb0f602017-10-11 08:37:54 +020054 }
55}