blob: 0e28a4e5c5a7e19725ec5072a922d6d3254d9a17 [file] [log] [blame]
Richard Felkl4ae811f2017-10-10 18:17:27 +02001/**
2 * Update mirror image
3 *
4 * Expected parameters:
5 * SALT_MASTER_CREDENTIALS Credentials to the Salt API.
6 * SALT_MASTER_URL Full Salt API address [https://10.10.10.1:8000].
7 *
8**/
9
10def common = new com.mirantis.mk.Common()
11def salt = new com.mirantis.mk.Salt()
12def python = new com.mirantis.mk.Python()
13def venvPepper = "venvPepper"
14
15node() {
16 try {
17
18 python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
19
20 stage('Update Aptly packages'){
21 common.infoMsg("Updating Aptly packages.")
Richard Felklf6ae7e22017-10-27 13:33:24 +020022 salt.enforceState(venvPepper, 'apt*', ['aptly'], true)
23 salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['/srv/scripts/aptly-update.sh'], null, true)
Richard Felkl4ae811f2017-10-10 18:17:27 +020024 }
25
26 stage('Update Docker images'){
27 common.infoMsg("Updating Docker images.")
Richard Felklf6ae7e22017-10-27 13:33:24 +020028 salt.enforceState(venvPepper, 'apt*', ['docker.client.registry'], true)
Richard Felkl4ae811f2017-10-10 18:17:27 +020029 }
30
31 stage('Update PyPi packages'){
32 common.infoMsg("Updating PyPi packages.")
Richard Felklf6ae7e22017-10-27 13:33:24 +020033 salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['pip2pi /srv/pypi_mirror/packages/ -r /srv/pypi_mirror/requirements.txt'], null, true)
Richard Felkl4ae811f2017-10-10 18:17:27 +020034 }
35
36 stage('Update Git repositories'){
37 common.infoMsg("Updating Git repositories.")
Richard Felklf6ae7e22017-10-27 13:33:24 +020038 salt.enforceState(venvPepper, 'apt*', ['git.server'], true)
Richard Felkl4ae811f2017-10-10 18:17:27 +020039 }
40
41 stage('Update VM images'){
42 common.infoMsg("Updating VM images.")
Richard Felklf6ae7e22017-10-27 13:33:24 +020043 salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['/srv/scripts/update-images.sh'], null, true)
Richard Felkl4ae811f2017-10-10 18:17:27 +020044 }
45
46 } catch (Throwable e) {
47 // If there was an error or exception thrown, the build failed
48 currentBuild.result = "FAILURE"
49 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
50 throw e
51 }
52}