blob: faf891cb0c6259f393c287f1c846b3a37183c449 [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
azvyagintsev3280a0c2018-07-31 08:44:43 +020061def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) {
azvyagintsev87781882018-08-30 18:45:22 +030062 build job: "tag-git-repos-stable", parameters: [
63 [$class: 'StringParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList],
64 [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials],
65 [$class: 'StringParameterValue', name: 'TAG', value: tag],
66 [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag],
67 ]
68}
69
70def triggerPromoteVCPJob(VcpImageList, tag, sourceTag) {
71 build job: "promote-vcp-images-all", parameters: [
72 [$class: 'StringParameterValue', name: 'VCP_IMAGE_LIST', value: VcpImageList],
73 [$class: 'StringParameterValue', name: 'TAG', value: tag],
74 [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag]
75 ]
Richard Felkl37ee1e32017-12-11 10:01:39 +010076}
Richard Felklc8c5a5a2018-04-19 17:06:30 +020077
Jakub Josefa63f9862018-01-11 17:58:38 +010078timeout(time: 12, unit: 'HOURS') {
azvyagintsev87781882018-08-30 18:45:22 +030079 node() {
80 try {
81 stage("Promote") {
82 if (RELEASE_APTLY.toBoolean()) {
83 common.infoMsg("Promoting Aptly")
84 triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}")
85 }
Richard Felkl56082e92017-12-20 23:39:53 +010086
azvyagintsev87781882018-08-30 18:45:22 +030087 if (RELEASE_DEB_MIRRORS.toBoolean()) {
88 common.infoMsg("Promoting Debmirrors")
89 triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION)
90 }
Richard Felkl56082e92017-12-20 23:39:53 +010091
azvyagintsev87781882018-08-30 18:45:22 +030092 if (RELEASE_DOCKER.toBoolean()) {
93 common.infoMsg("Promoting Docker images")
94 triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION)
95 }
Richard Felkl56082e92017-12-20 23:39:53 +010096
azvyagintsev87781882018-08-30 18:45:22 +030097 if (RELEASE_GIT.toBoolean()) {
98 common.infoMsg("Promoting Git repositories")
99 triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION)
Richard Felklc8c5a5a2018-04-19 17:06:30 +0200100
azvyagintsev87781882018-08-30 18:45:22 +0300101 }
102 if (RELEASE_VCP_IMAGES.toBoolean()) {
103 common.infoMsg("Promoting VCP images")
104 triggerPromoteVCPJob(VCP_IMAGE_LIST, TARGET_REVISION, SOURCE_REVISION)
105
106 }
107 if (EMAIL_NOTIFY.toBoolean()) {
108 emailext(to: NOTIFY_RECIPIENTS,
109 body: NOTIFY_TEXT,
110 subject: "MCP Promotion has been done")
111 }
112 }
113 } catch (Throwable e) {
Jakub Josefa63f9862018-01-11 17:58:38 +0100114 // If there was an error or exception thrown, the build failed
115 currentBuild.result = "FAILURE"
116 throw e
Richard Felkl37ee1e32017-12-11 10:01:39 +0100117 }
azvyagintsev87781882018-08-30 18:45:22 +0300118 }
119}