blob: 0b570fca8306c7a99e37fff7a2590b2391253ed1 [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"
16
17node() {
18 try {
19 python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
20
21 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")
30 salt.runSaltProcessStep(venvPepper, 'jma*', 'saltutil.sync_all', [], null, true)
31 }
32 }
33 stage("Update Reclass") {
34 common.infoMsg("Updating reclass model")
35 salt.cmdRun(
36 venvPepper,
37 "I@salt:master",
38 'cd /srv/salt/reclass && git pull -r && git submodule update',
39 false
40 )
41
42 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
53 }
54}