Richard Felkl | 4ae811f | 2017-10-10 18:17:27 +0200 | [diff] [blame] | 1 | /** |
| 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 | |
| 10 | def common = new com.mirantis.mk.Common() |
| 11 | def salt = new com.mirantis.mk.Salt() |
| 12 | def python = new com.mirantis.mk.Python() |
| 13 | def venvPepper = "venvPepper" |
| 14 | |
| 15 | node() { |
| 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 Felkl | f6ae7e2 | 2017-10-27 13:33:24 +0200 | [diff] [blame] | 22 | salt.enforceState(venvPepper, 'apt*', ['aptly'], true) |
| 23 | salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['/srv/scripts/aptly-update.sh'], null, true) |
Richard Felkl | 4ae811f | 2017-10-10 18:17:27 +0200 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | stage('Update Docker images'){ |
| 27 | common.infoMsg("Updating Docker images.") |
Richard Felkl | f6ae7e2 | 2017-10-27 13:33:24 +0200 | [diff] [blame] | 28 | salt.enforceState(venvPepper, 'apt*', ['docker.client.registry'], true) |
Richard Felkl | 4ae811f | 2017-10-10 18:17:27 +0200 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | stage('Update PyPi packages'){ |
| 32 | common.infoMsg("Updating PyPi packages.") |
Richard Felkl | f6ae7e2 | 2017-10-27 13:33:24 +0200 | [diff] [blame] | 33 | salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['pip2pi /srv/pypi_mirror/packages/ -r /srv/pypi_mirror/requirements.txt'], null, true) |
Richard Felkl | 4ae811f | 2017-10-10 18:17:27 +0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | stage('Update Git repositories'){ |
| 37 | common.infoMsg("Updating Git repositories.") |
Richard Felkl | f6ae7e2 | 2017-10-27 13:33:24 +0200 | [diff] [blame] | 38 | salt.enforceState(venvPepper, 'apt*', ['git.server'], true) |
Richard Felkl | 4ae811f | 2017-10-10 18:17:27 +0200 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | stage('Update VM images'){ |
| 42 | common.infoMsg("Updating VM images.") |
Richard Felkl | f6ae7e2 | 2017-10-27 13:33:24 +0200 | [diff] [blame] | 43 | salt.runSaltProcessStep(venvPepper, 'apt*', 'cmd.run', ['/srv/scripts/update-images.sh'], null, true) |
Richard Felkl | 4ae811f | 2017-10-10 18:17:27 +0200 | [diff] [blame] | 44 | } |
| 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 | } |