blob: 4cae93c2bc9a5db80306422e1fdc9dd75c49f55f [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],
49 [$class: 'StringParameterValue', name: 'IMAGE_LIST', value: imageList],
50 [$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) {
azvyagintsev21308d02018-08-30 17:49:33 +030069 build job: "tag-git-repos-all", parameters: [
azvyagintsev87781882018-08-30 18:45:22 +030070 [$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
77def 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 Felkl37ee1e32017-12-11 10:01:39 +010083}
Richard Felklc8c5a5a2018-04-19 17:06:30 +020084
Jakub Josefa63f9862018-01-11 17:58:38 +010085timeout(time: 12, unit: 'HOURS') {
azvyagintsev87781882018-08-30 18:45:22 +030086 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 Felkl56082e92017-12-20 23:39:53 +010093
azvyagintsev87781882018-08-30 18:45:22 +030094 if (RELEASE_DEB_MIRRORS.toBoolean()) {
95 common.infoMsg("Promoting Debmirrors")
96 triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION)
97 }
Richard Felkl56082e92017-12-20 23:39:53 +010098
Alexander Evseeve704ca92018-09-11 11:30:55 +020099 if (RELEASE_EBF_MIRRORS.toBoolean()) {
100 common.infoMsg("Promoting Emergency Bug Fix Debmirrors")
101 triggerEbfRepoJob(SOURCE_REVISION, TARGET_REVISION)
102 }
103
azvyagintsev87781882018-08-30 18:45:22 +0300104 if (RELEASE_DOCKER.toBoolean()) {
105 common.infoMsg("Promoting Docker images")
106 triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION)
107 }
Richard Felkl56082e92017-12-20 23:39:53 +0100108
azvyagintsev87781882018-08-30 18:45:22 +0300109 if (RELEASE_GIT.toBoolean()) {
110 common.infoMsg("Promoting Git repositories")
111 triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION)
Richard Felklc8c5a5a2018-04-19 17:06:30 +0200112
azvyagintsev87781882018-08-30 18:45:22 +0300113 }
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 Josefa63f9862018-01-11 17:58:38 +0100126 // If there was an error or exception thrown, the build failed
127 currentBuild.result = "FAILURE"
128 throw e
Richard Felkl37ee1e32017-12-11 10:01:39 +0100129 }
azvyagintsev87781882018-08-30 18:45:22 +0300130 }
131}