blob: 652dae9ead867223c5f772bb330efcc5b1615394 [file] [log] [blame]
Richard Felkl37ee1e32017-12-11 10:01:39 +01001/**
2 *
Richard Felkl56082e92017-12-20 23:39:53 +01003 * Promote MCP
Richard Felkl37ee1e32017-12-11 10:01:39 +01004 *
5 * Expected parameters:
Richard Felkl56082e92017-12-20 23:39:53 +01006 * SOURCE_REVISION
7 * TARGET_REVISION
Richard Felkl37ee1e32017-12-11 10:01:39 +01008 * RELEASE_APTLY
Richard Felkl56082e92017-12-20 23:39:53 +01009 * RELEASE_DEB_MIRRORS
Richard Felkl37ee1e32017-12-11 10:01:39 +010010 * 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
azvyagintsev87781882018-08-30 18:45:22 +030019 * VCP_IMAGE_LIST - list of images
20 * RELEASE_VCP_IMAGES - boolean
Richard Felklc8c5a5a2018-04-19 17:06:30 +020021 * EMAIL_NOTIFY
22 * NOTIFY_RECIPIENTS
23 * NOTIFY_TEXT
24 *
azvyagintsev87781882018-08-30 18:45:22 +030025 */
Richard Felkl37ee1e32017-12-11 10:01:39 +010026
Richard Felkl55175f52017-12-20 14:53:41 +010027common = new com.mirantis.mk.Common()
28git = new com.mirantis.mk.Git()
Richard Felkl37ee1e32017-12-11 10:01:39 +010029
azvyagintsev87781882018-08-30 18:45:22 +030030def 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 Felkl37ee1e32017-12-11 10:01:39 +010042}
43
azvyagintsevd162b912018-07-26 10:52:14 +020044def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList, sourceImageTag) {
azvyagintsev87781882018-08-30 18:45:22 +030045 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],
azvyagintsevf7c65fa2018-10-02 14:59:09 +030049 [$class: 'TextParameterValue', name: 'IMAGE_LIST', value: imageList],
azvyagintsev87781882018-08-30 18:45:22 +030050 [$class: 'StringParameterValue', name: 'SOURCE_IMAGE_TAG', value: sourceImageTag],
51 ]
Richard Felkl37ee1e32017-12-11 10:01:39 +010052}
53
Richard Felkl56082e92017-12-20 23:39:53 +010054def triggerMirrorRepoJob(snapshotId, snapshotName) {
azvyagintsev87781882018-08-30 18:45:22 +030055 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 Felkl56082e92017-12-20 23:39:53 +010059}
60
Alexander Evseeve704ca92018-09-11 11:30:55 +020061def 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
azvyagintsev3280a0c2018-07-31 08:44:43 +020068def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) {
Alexander Evseev85649372018-10-08 18:06:49 +020069 // There is no `nightly` and `testing` build-IDs` in release process
70 // for git repos
71 if ( sourceTag in ['nightly', 'testing'] ) sourceTag = 'master'
azvyagintsev21308d02018-08-30 17:49:33 +030072 build job: "tag-git-repos-all", parameters: [
azvyagintsevf7c65fa2018-10-02 14:59:09 +030073 [$class: 'TextParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList],
azvyagintsev87781882018-08-30 18:45:22 +030074 [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials],
75 [$class: 'StringParameterValue', name: 'TAG', value: tag],
76 [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag],
77 ]
78}
79
80def triggerPromoteVCPJob(VcpImageList, tag, sourceTag) {
81 build job: "promote-vcp-images-all", parameters: [
azvyagintsevf7c65fa2018-10-02 14:59:09 +030082 [$class: 'TextParameterValue', name: 'VCP_IMAGE_LIST', value: VcpImageList],
azvyagintsev87781882018-08-30 18:45:22 +030083 [$class: 'StringParameterValue', name: 'TAG', value: tag],
azvyagintsevff65d402018-10-02 18:37:42 +030084 [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag],
85 [$class: 'BooleanParameterValue', name: 'FORCE_OVERWRITE', value: true],
azvyagintsev87781882018-08-30 18:45:22 +030086 ]
Richard Felkl37ee1e32017-12-11 10:01:39 +010087}
Richard Felklc8c5a5a2018-04-19 17:06:30 +020088
Jakub Josefa63f9862018-01-11 17:58:38 +010089timeout(time: 12, unit: 'HOURS') {
azvyagintsev87781882018-08-30 18:45:22 +030090 node() {
91 try {
92 stage("Promote") {
93 if (RELEASE_APTLY.toBoolean()) {
94 common.infoMsg("Promoting Aptly")
95 triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}")
96 }
Richard Felkl56082e92017-12-20 23:39:53 +010097
azvyagintsev87781882018-08-30 18:45:22 +030098 if (RELEASE_DEB_MIRRORS.toBoolean()) {
99 common.infoMsg("Promoting Debmirrors")
100 triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION)
101 }
Richard Felkl56082e92017-12-20 23:39:53 +0100102
Alexander Evseeve704ca92018-09-11 11:30:55 +0200103 if (RELEASE_EBF_MIRRORS.toBoolean()) {
104 common.infoMsg("Promoting Emergency Bug Fix Debmirrors")
105 triggerEbfRepoJob(SOURCE_REVISION, TARGET_REVISION)
106 }
107
azvyagintsev87781882018-08-30 18:45:22 +0300108 if (RELEASE_DOCKER.toBoolean()) {
109 common.infoMsg("Promoting Docker images")
110 triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION)
111 }
Richard Felkl56082e92017-12-20 23:39:53 +0100112
azvyagintsev87781882018-08-30 18:45:22 +0300113 if (RELEASE_GIT.toBoolean()) {
114 common.infoMsg("Promoting Git repositories")
115 triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION)
Richard Felklc8c5a5a2018-04-19 17:06:30 +0200116
azvyagintsev87781882018-08-30 18:45:22 +0300117 }
118 if (RELEASE_VCP_IMAGES.toBoolean()) {
119 common.infoMsg("Promoting VCP images")
120 triggerPromoteVCPJob(VCP_IMAGE_LIST, TARGET_REVISION, SOURCE_REVISION)
121
122 }
123 if (EMAIL_NOTIFY.toBoolean()) {
124 emailext(to: NOTIFY_RECIPIENTS,
125 body: NOTIFY_TEXT,
126 subject: "MCP Promotion has been done")
127 }
128 }
129 } catch (Throwable e) {
Jakub Josefa63f9862018-01-11 17:58:38 +0100130 // If there was an error or exception thrown, the build failed
131 currentBuild.result = "FAILURE"
132 throw e
Richard Felkl37ee1e32017-12-11 10:01:39 +0100133 }
azvyagintsev87781882018-08-30 18:45:22 +0300134 }
135}