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 |
azvyagintsev | 759734c | 2018-10-03 13:57:54 +0300 | [diff] [blame] | 20 | * SYNC_VCP_IMAGE_TO_S3 - boolean |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 21 | * RELEASE_VCP_IMAGES - boolean |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 22 | * EMAIL_NOTIFY |
| 23 | * NOTIFY_RECIPIENTS |
Sergey Otpuschennikov | 6f4d685 | 2018-12-27 19:27:58 +0400 | [diff] [blame] | 24 | * PKG_REPO_LIST |
azvyagintsev | 4696d66 | 2018-11-23 19:48:09 +0200 | [diff] [blame] | 25 | * |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 26 | */ |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 27 | |
Richard Felkl | 55175f5 | 2017-12-20 14:53:41 +0100 | [diff] [blame] | 28 | common = new com.mirantis.mk.Common() |
azvyagintsev | 759734c | 2018-10-03 13:57:54 +0300 | [diff] [blame] | 29 | |
azvyagintsev | 7977866 | 2018-11-23 18:07:16 +0200 | [diff] [blame] | 30 | syncVcpImagesToS3 = env.SYNC_VCP_IMAGE_TO_S3 ?: false |
| 31 | emailNotify = env.EMAIL_NOTIFY ?: false |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 32 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 33 | def triggerAptlyPromoteJob(aptlyUrl, components, diffOnly, dumpPublish, packages, recreate, source, storages, target) { |
| 34 | build job: "aptly-promote-all-testing-stable", parameters: [ |
| 35 | [$class: 'StringParameterValue', name: 'APTLY_URL', value: aptlyUrl], |
| 36 | [$class: 'StringParameterValue', name: 'COMPONENTS', value: components], |
| 37 | [$class: 'BooleanParameterValue', name: 'DIFF_ONLY', value: diffOnly], |
| 38 | [$class: 'BooleanParameterValue', name: 'DUMP_PUBLISH', value: dumpPublish], |
| 39 | [$class: 'StringParameterValue', name: 'PACKAGES', value: packages], |
| 40 | [$class: 'BooleanParameterValue', name: 'RECREATE', value: recreate], |
| 41 | [$class: 'StringParameterValue', name: 'SOURCE', value: source], |
| 42 | [$class: 'StringParameterValue', name: 'STORAGES', value: storages], |
| 43 | [$class: 'StringParameterValue', name: 'TARGET', value: target], |
| 44 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 45 | } |
| 46 | |
azvyagintsev | d162b91 | 2018-07-26 10:52:14 +0200 | [diff] [blame] | 47 | def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList, sourceImageTag) { |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 48 | build job: "docker-images-mirror", parameters: [ |
| 49 | [$class: 'StringParameterValue', name: 'TARGET_REGISTRY_CREDENTIALS_ID', value: dockerCredentials], |
| 50 | [$class: 'StringParameterValue', name: 'REGISTRY_URL', value: dockerRegistryUrl], |
| 51 | [$class: 'StringParameterValue', name: 'IMAGE_TAG', value: targetTag], |
azvyagintsev | f7c65fa | 2018-10-02 14:59:09 +0300 | [diff] [blame] | 52 | [$class: 'TextParameterValue', name: 'IMAGE_LIST', value: imageList], |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 53 | [$class: 'StringParameterValue', name: 'SOURCE_IMAGE_TAG', value: sourceImageTag], |
| 54 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 57 | def triggerMirrorRepoJob(snapshotId, snapshotName) { |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 58 | build job: "mirror-snapshot-name-all", parameters: [ |
| 59 | [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName], |
| 60 | [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId], |
| 61 | ] |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 62 | } |
| 63 | |
Alexander Evseev | e704ca9 | 2018-09-11 11:30:55 +0200 | [diff] [blame] | 64 | def triggerEbfRepoJob(snapshotId, snapshotName) { |
| 65 | build job: "ebf-snapshot-name-all", parameters: [ |
| 66 | [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName], |
| 67 | [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId], |
| 68 | ] |
| 69 | } |
| 70 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame] | 71 | def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) { |
Alexander Evseev | 8564937 | 2018-10-08 18:06:49 +0200 | [diff] [blame] | 72 | // There is no `nightly` and `testing` build-IDs` in release process |
| 73 | // for git repos |
azvyagintsev | 5830122 | 2019-01-08 13:34:35 +0200 | [diff] [blame] | 74 | if (sourceTag in ['nightly', 'testing']) { |
| 75 | sourceTag = 'master' |
| 76 | } |
azvyagintsev | 21308d0 | 2018-08-30 17:49:33 +0300 | [diff] [blame] | 77 | build job: "tag-git-repos-all", parameters: [ |
azvyagintsev | f7c65fa | 2018-10-02 14:59:09 +0300 | [diff] [blame] | 78 | [$class: 'TextParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList], |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 79 | [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials], |
| 80 | [$class: 'StringParameterValue', name: 'TAG', value: tag], |
| 81 | [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag], |
| 82 | ] |
| 83 | } |
| 84 | |
| 85 | def triggerPromoteVCPJob(VcpImageList, tag, sourceTag) { |
| 86 | build job: "promote-vcp-images-all", parameters: [ |
azvyagintsev | f7c65fa | 2018-10-02 14:59:09 +0300 | [diff] [blame] | 87 | [$class: 'TextParameterValue', name: 'VCP_IMAGE_LIST', value: VcpImageList], |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 88 | [$class: 'StringParameterValue', name: 'TAG', value: tag], |
azvyagintsev | ff65d40 | 2018-10-02 18:37:42 +0300 | [diff] [blame] | 89 | [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag], |
| 90 | [$class: 'BooleanParameterValue', name: 'FORCE_OVERWRITE', value: true], |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 91 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 92 | } |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 93 | |
Sergey Otpuschennikov | b0c4db7 | 2018-12-19 19:12:54 +0400 | [diff] [blame] | 94 | def triggerPkgPromoteJob(PkgRepoList, PromoteFrom, PromoteTo) { |
Sergey Otpuschennikov | 6f4d685 | 2018-12-27 19:27:58 +0400 | [diff] [blame] | 95 | //For repositories with per-package promote such as extra, ceph |
| 96 | //we use different approaches for different steps of promoting |
Sergey Otpuschennikov | 9b532cd | 2019-02-06 17:03:33 +0400 | [diff] [blame] | 97 | def repos = PkgRepoList.trim().tokenize("\n") |
Sergey Otpuschennikov | b0c4db7 | 2018-12-19 19:12:54 +0400 | [diff] [blame] | 98 | def RepoName, RepoDist, PackagesToPromote |
| 99 | for (repo in repos) { |
azvyagintsev | 5830122 | 2019-01-08 13:34:35 +0200 | [diff] [blame] | 100 | if (repo.startsWith('#')) { |
Sergey Otpuschennikov | b0c4db7 | 2018-12-19 19:12:54 +0400 | [diff] [blame] | 101 | common.warningMsg("Skipping repo ${repo}") |
| 102 | continue |
| 103 | } |
azvyagintsev | 5830122 | 2019-01-08 13:34:35 +0200 | [diff] [blame] | 104 | if (repo.trim().indexOf(' ') == -1) { |
| 105 | throw new IllegalArgumentException("Wrong format of repository and commit input") |
Sergey Otpuschennikov | b0c4db7 | 2018-12-19 19:12:54 +0400 | [diff] [blame] | 106 | } |
| 107 | repoArray = repo.trim().tokenize(' ') |
| 108 | RepoName = repoArray[0] |
| 109 | RepoDist = repoArray[1] |
| 110 | PackagesToPromote = repoArray[2] |
Sergey Otpuschennikov | 6f4d685 | 2018-12-27 19:27:58 +0400 | [diff] [blame] | 111 | //During promote from testing to proposed we use per-package promote |
| 112 | if (SOURCE_REVISION == 'testing') { |
| 113 | build job: "pkg-promote", parameters: [ |
Sergey Otpuschennikov | 9b532cd | 2019-02-06 17:03:33 +0400 | [diff] [blame] | 114 | [$class: 'StringParameterValue', name: 'repoName', value: RepoName], |
| 115 | [$class: 'StringParameterValue', name: 'repoDist', value: RepoDist], |
| 116 | [$class: 'StringParameterValue', name: 'promoteFrom', value: PromoteFrom], |
| 117 | [$class: 'StringParameterValue', name: 'promoteTo', value: PromoteTo], |
Sergey Otpuschennikov | 6f4d685 | 2018-12-27 19:27:58 +0400 | [diff] [blame] | 118 | [$class: 'TextParameterValue', name: 'packagesToPromote', value: PackagesToPromote], |
| 119 | ] |
| 120 | //In promote from proposed to release we move links to snapshots |
| 121 | } else if (SOURCE_REVISION == 'proposed') { |
| 122 | build job: "mirror-snapshot-pkg-name-${RepoName}-${RepoDist}", parameters: [ |
Sergey Otpuschennikov | 37ad0bc | 2019-02-06 17:30:36 +0400 | [diff] [blame] | 123 | [$class: 'StringParameterValue', name: 'MCP_VERSION', value: PromoteTo], |
| 124 | [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: PromoteFrom], |
Sergey Otpuschennikov | 6f4d685 | 2018-12-27 19:27:58 +0400 | [diff] [blame] | 125 | ] |
| 126 | } |
Sergey Otpuschennikov | b0c4db7 | 2018-12-19 19:12:54 +0400 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
azvyagintsev | 7977866 | 2018-11-23 18:07:16 +0200 | [diff] [blame] | 130 | def triggerSyncVCPJob(VcpImageList, targetTag) { |
| 131 | // Operation must be synced with triggerPromoteVCPJob procedure! |
| 132 | def images = VcpImageList.trim().tokenize() |
| 133 | TargetVcpImageList = '' |
| 134 | for (image in images) { |
| 135 | if (image.startsWith('#')) { |
| 136 | common.warningMsg("Skipping image ${image}") |
| 137 | continue |
| 138 | } |
| 139 | common.infoMsg("Replacing SUBS_SOURCE_VCP_IMAGE_TAG => ${targetTag}") |
azvyagintsev | 4696d66 | 2018-11-23 19:48:09 +0200 | [diff] [blame] | 140 | TargetVcpImageList += image.replace('SUBS_SOURCE_VCP_IMAGE_TAG', targetTag) + '\n' + |
| 141 | image.replace('SUBS_SOURCE_VCP_IMAGE_TAG', targetTag).trim() + '.md5' + '\n' |
| 142 | |
azvyagintsev | 7977866 | 2018-11-23 18:07:16 +0200 | [diff] [blame] | 143 | } |
Kirill Mashchenko | e866b30 | 2018-11-23 21:08:15 +0400 | [diff] [blame] | 144 | build job: "upload_images_to_s3", parameters: [ |
azvyagintsev | 4696d66 | 2018-11-23 19:48:09 +0200 | [diff] [blame] | 145 | [$class: 'TextParameterValue', name: 'FILENAMES', |
| 146 | value : TargetVcpImageList] |
azvyagintsev | 759734c | 2018-10-03 13:57:54 +0300 | [diff] [blame] | 147 | ] |
| 148 | } |
| 149 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 150 | timeout(time: 12, unit: 'HOURS') { |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 151 | node() { |
| 152 | try { |
| 153 | stage("Promote") { |
| 154 | if (RELEASE_APTLY.toBoolean()) { |
| 155 | common.infoMsg("Promoting Aptly") |
| 156 | triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}") |
| 157 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 158 | |
Sergey Otpuschennikov | 6f4d685 | 2018-12-27 19:27:58 +0400 | [diff] [blame] | 159 | if (PKG_PROMOTE.toBoolean()) { |
Sergey Otpuschennikov | b0c4db7 | 2018-12-19 19:12:54 +0400 | [diff] [blame] | 160 | common.infoMsg("Promoting Extra and Ceph packages") |
| 161 | triggerPkgPromoteJob(PKG_REPO_LIST, SOURCE_REVISION, TARGET_REVISION) |
| 162 | } |
| 163 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 164 | if (RELEASE_DEB_MIRRORS.toBoolean()) { |
| 165 | common.infoMsg("Promoting Debmirrors") |
| 166 | triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION) |
| 167 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 168 | |
Alexander Evseev | e704ca9 | 2018-09-11 11:30:55 +0200 | [diff] [blame] | 169 | if (RELEASE_EBF_MIRRORS.toBoolean()) { |
| 170 | common.infoMsg("Promoting Emergency Bug Fix Debmirrors") |
| 171 | triggerEbfRepoJob(SOURCE_REVISION, TARGET_REVISION) |
| 172 | } |
| 173 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 174 | if (RELEASE_DOCKER.toBoolean()) { |
| 175 | common.infoMsg("Promoting Docker images") |
| 176 | triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION) |
| 177 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 178 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 179 | if (RELEASE_GIT.toBoolean()) { |
| 180 | common.infoMsg("Promoting Git repositories") |
| 181 | triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION) |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 182 | |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 183 | } |
| 184 | if (RELEASE_VCP_IMAGES.toBoolean()) { |
| 185 | common.infoMsg("Promoting VCP images") |
| 186 | triggerPromoteVCPJob(VCP_IMAGE_LIST, TARGET_REVISION, SOURCE_REVISION) |
| 187 | |
| 188 | } |
azvyagintsev | 7977866 | 2018-11-23 18:07:16 +0200 | [diff] [blame] | 189 | if (syncVcpImagesToS3.toBoolean()) { |
Alexander Evseev | 1edde6b | 2018-10-30 15:22:44 +0300 | [diff] [blame] | 190 | common.infoMsg("Syncing VCP images from internal: http://images.mcp.mirantis.net/ to s3: images.mirantis.com") |
azvyagintsev | 7977866 | 2018-11-23 18:07:16 +0200 | [diff] [blame] | 191 | triggerSyncVCPJob(VCP_IMAGE_LIST, TARGET_REVISION) |
azvyagintsev | 759734c | 2018-10-03 13:57:54 +0300 | [diff] [blame] | 192 | } |
| 193 | if (emailNotify) { |
| 194 | notify_text = "MCP Promotion ${env.SOURCE_REVISION} => ${env.TARGET_REVISION} has been done" |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 195 | emailext(to: NOTIFY_RECIPIENTS, |
azvyagintsev | 759734c | 2018-10-03 13:57:54 +0300 | [diff] [blame] | 196 | body: notify_text, |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 197 | subject: "MCP Promotion has been done") |
| 198 | } |
| 199 | } |
| 200 | } catch (Throwable e) { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 201 | // If there was an error or exception thrown, the build failed |
| 202 | currentBuild.result = "FAILURE" |
| 203 | throw e |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 204 | } |
azvyagintsev | 8778188 | 2018-08-30 18:45:22 +0300 | [diff] [blame] | 205 | } |
| 206 | } |