Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 1 | /** |
| 2 | * |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 3 | * Promote MCP |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 4 | * |
| 5 | * Expected parameters: |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 6 | * SOURCE_REVISION |
| 7 | * TARGET_REVISION |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 8 | * RELEASE_APTLY |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 9 | * RELEASE_DEB_MIRRORS |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 10 | * RELEASE_DOCKER |
| 11 | * RELEASE_GIT |
| 12 | * APTLY_URL |
| 13 | * APTLY_STORAGES |
| 14 | * DOCKER_CREDENTIALS |
| 15 | * DOCKER_URL |
| 16 | * DOCKER_IMAGES |
| 17 | * GIT_CREDENTIALS |
| 18 | * GIT_REPO_LIST |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 19 | * VCP_IMAGE_LIST - list of images |
| 20 | * RELEASE_VCP_IMAGES - boolean |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 21 | * EMAIL_NOTIFY |
| 22 | * NOTIFY_RECIPIENTS |
| 23 | * NOTIFY_TEXT |
| 24 | * |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 25 | */ |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 26 | |
Richard Felkl | 55175f5 | 2017-12-20 14:53:41 +0100 | [diff] [blame] | 27 | common = new com.mirantis.mk.Common() |
| 28 | git = new com.mirantis.mk.Git() |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 29 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 30 | def triggerAptlyPromoteJob(aptlyUrl, components, diffOnly, dumpPublish, packages, recreate, source, storages, target) { |
| 31 | build job: "aptly-promote-all-testing-stable", parameters: [ |
| 32 | [$class: 'StringParameterValue', name: 'APTLY_URL', value: aptlyUrl], |
| 33 | [$class: 'StringParameterValue', name: 'COMPONENTS', value: components], |
| 34 | [$class: 'BooleanParameterValue', name: 'DIFF_ONLY', value: diffOnly], |
| 35 | [$class: 'BooleanParameterValue', name: 'DUMP_PUBLISH', value: dumpPublish], |
| 36 | [$class: 'StringParameterValue', name: 'PACKAGES', value: packages], |
| 37 | [$class: 'BooleanParameterValue', name: 'RECREATE', value: recreate], |
| 38 | [$class: 'StringParameterValue', name: 'SOURCE', value: source], |
| 39 | [$class: 'StringParameterValue', name: 'STORAGES', value: storages], |
| 40 | [$class: 'StringParameterValue', name: 'TARGET', value: target], |
| 41 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 42 | } |
| 43 | |
azvyagintsev | d162b91 | 2018-07-26 10:52:14 +0200 | [diff] [blame] | 44 | def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList, sourceImageTag) { |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 45 | build job: "docker-images-mirror", parameters: [ |
| 46 | [$class: 'StringParameterValue', name: 'TARGET_REGISTRY_CREDENTIALS_ID', value: dockerCredentials], |
| 47 | [$class: 'StringParameterValue', name: 'REGISTRY_URL', value: dockerRegistryUrl], |
| 48 | [$class: 'StringParameterValue', name: 'IMAGE_TAG', value: targetTag], |
| 49 | [$class: 'StringParameterValue', name: 'IMAGE_LIST', value: imageList], |
| 50 | [$class: 'StringParameterValue', name: 'SOURCE_IMAGE_TAG', value: sourceImageTag], |
| 51 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 54 | def triggerMirrorRepoJob(snapshotId, snapshotName) { |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 55 | build job: "mirror-snapshot-name-all", parameters: [ |
| 56 | [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName], |
| 57 | [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId], |
| 58 | ] |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Alexander Evseev | e704ca9 | 2018-09-11 11:30:55 +0200 | [diff] [blame^] | 61 | def triggerEbfRepoJob(snapshotId, snapshotName) { |
| 62 | build job: "ebf-snapshot-name-all", parameters: [ |
| 63 | [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName], |
| 64 | [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId], |
| 65 | ] |
| 66 | } |
| 67 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame] | 68 | def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) { |
azvyagintsev | 21308d0 | 2018-08-30 17:49:33 +0300 | [diff] [blame] | 69 | build job: "tag-git-repos-all", parameters: [ |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 70 | [$class: 'StringParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList], |
| 71 | [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials], |
| 72 | [$class: 'StringParameterValue', name: 'TAG', value: tag], |
| 73 | [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag], |
| 74 | ] |
| 75 | } |
| 76 | |
| 77 | def triggerPromoteVCPJob(VcpImageList, tag, sourceTag) { |
| 78 | build job: "promote-vcp-images-all", parameters: [ |
| 79 | [$class: 'StringParameterValue', name: 'VCP_IMAGE_LIST', value: VcpImageList], |
| 80 | [$class: 'StringParameterValue', name: 'TAG', value: tag], |
| 81 | [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag] |
| 82 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 83 | } |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 84 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 85 | timeout(time: 12, unit: 'HOURS') { |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 86 | node() { |
| 87 | try { |
| 88 | stage("Promote") { |
| 89 | if (RELEASE_APTLY.toBoolean()) { |
| 90 | common.infoMsg("Promoting Aptly") |
| 91 | triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}") |
| 92 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 93 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 94 | if (RELEASE_DEB_MIRRORS.toBoolean()) { |
| 95 | common.infoMsg("Promoting Debmirrors") |
| 96 | triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION) |
| 97 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 98 | |
Alexander Evseev | e704ca9 | 2018-09-11 11:30:55 +0200 | [diff] [blame^] | 99 | if (RELEASE_EBF_MIRRORS.toBoolean()) { |
| 100 | common.infoMsg("Promoting Emergency Bug Fix Debmirrors") |
| 101 | triggerEbfRepoJob(SOURCE_REVISION, TARGET_REVISION) |
| 102 | } |
| 103 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 104 | if (RELEASE_DOCKER.toBoolean()) { |
| 105 | common.infoMsg("Promoting Docker images") |
| 106 | triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION) |
| 107 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 108 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 109 | if (RELEASE_GIT.toBoolean()) { |
| 110 | common.infoMsg("Promoting Git repositories") |
| 111 | triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION) |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 112 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 113 | } |
| 114 | if (RELEASE_VCP_IMAGES.toBoolean()) { |
| 115 | common.infoMsg("Promoting VCP images") |
| 116 | triggerPromoteVCPJob(VCP_IMAGE_LIST, TARGET_REVISION, SOURCE_REVISION) |
| 117 | |
| 118 | } |
| 119 | if (EMAIL_NOTIFY.toBoolean()) { |
| 120 | emailext(to: NOTIFY_RECIPIENTS, |
| 121 | body: NOTIFY_TEXT, |
| 122 | subject: "MCP Promotion has been done") |
| 123 | } |
| 124 | } |
| 125 | } catch (Throwable e) { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 126 | // If there was an error or exception thrown, the build failed |
| 127 | currentBuild.result = "FAILURE" |
| 128 | throw e |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 129 | } |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 130 | } |
| 131 | } |