blob: 7c30f30f5823ec4a412be2431694d0ee640eddb0 [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
Richard Felklc8c5a5a2018-04-19 17:06:30 +020019 * EMAIL_NOTIFY
20 * NOTIFY_RECIPIENTS
21 * NOTIFY_TEXT
22 *
Richard Felkl37ee1e32017-12-11 10:01:39 +010023 */
24
Richard Felkl55175f52017-12-20 14:53:41 +010025common = new com.mirantis.mk.Common()
26git = new com.mirantis.mk.Git()
Richard Felkl37ee1e32017-12-11 10:01:39 +010027
28def triggerAptlyPromoteJob(aptlyUrl, components, diffOnly, dumpPublish, packages, recreate, source, storages, target){
29 build job: "aptly-promote-all-testing-stable", parameters: [
30 [$class: 'StringParameterValue', name: 'APTLY_URL', value: aptlyUrl],
31 [$class: 'StringParameterValue', name: 'COMPONENTS', value: components],
32 [$class: 'BooleanParameterValue', name: 'DIFF_ONLY', value: diffOnly],
33 [$class: 'BooleanParameterValue', name: 'DUMP_PUBLISH', value: dumpPublish],
34 [$class: 'StringParameterValue', name: 'PACKAGES', value: packages],
35 [$class: 'BooleanParameterValue', name: 'RECREATE', value: recreate],
36 [$class: 'StringParameterValue', name: 'SOURCE', value: source],
37 [$class: 'StringParameterValue', name: 'STORAGES', value: storages],
38 [$class: 'StringParameterValue', name: 'TARGET', value: target]
39 ]
40}
41
azvyagintsevd162b912018-07-26 10:52:14 +020042def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList, sourceImageTag) {
Richard Felkl55175f52017-12-20 14:53:41 +010043 build job: "docker-images-mirror", parameters: [
Richard Felkl37ee1e32017-12-11 10:01:39 +010044 [$class: 'StringParameterValue', name: 'TARGET_REGISTRY_CREDENTIALS_ID', value: dockerCredentials],
45 [$class: 'StringParameterValue', name: 'REGISTRY_URL', value: dockerRegistryUrl],
Richard Felkl56082e92017-12-20 23:39:53 +010046 [$class: 'StringParameterValue', name: 'IMAGE_TAG', value: targetTag],
azvyagintsevd162b912018-07-26 10:52:14 +020047 [$class: 'StringParameterValue', name: 'IMAGE_LIST', value: imageList],
48 [$class: 'StringParameterValue', name: 'SOURCE_IMAGE_TAG', value: sourceImageTag]
Richard Felkl37ee1e32017-12-11 10:01:39 +010049 ]
50}
51
Richard Felkl56082e92017-12-20 23:39:53 +010052def triggerMirrorRepoJob(snapshotId, snapshotName) {
53 build job: "mirror-snapshot-name-all", parameters: [
54 [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName],
55 [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId]
56 ]
57}
58
Richard Felklc8c5a5a2018-04-19 17:06:30 +020059def triggerGitTagJob(gitRepoList, gitCredentials, tag) {
Richard Felkld16bd482018-04-24 20:04:28 +020060 build job: "tag-git-repos-stable", parameters: [
Richard Felklc8c5a5a2018-04-19 17:06:30 +020061 [$class: 'StringParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList],
62 [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials],
63 [$class: 'StringParameterValue', name: 'TAG', value: tag]
64 ]
Richard Felkl37ee1e32017-12-11 10:01:39 +010065}
Richard Felklc8c5a5a2018-04-19 17:06:30 +020066
Jakub Josefa63f9862018-01-11 17:58:38 +010067timeout(time: 12, unit: 'HOURS') {
68 node() {
69 try {
Richard Felkl56082e92017-12-20 23:39:53 +010070 stage("Promote"){
71 if(RELEASE_APTLY.toBoolean())
72 {
73 common.infoMsg("Promoting Aptly")
74 triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}")
Richard Felkl37ee1e32017-12-11 10:01:39 +010075 }
Richard Felkl56082e92017-12-20 23:39:53 +010076
77 if(RELEASE_DEB_MIRRORS.toBoolean()){
78 common.infoMsg("Promoting Debmirrors")
79 triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION)
Jakub Josefa63f9862018-01-11 17:58:38 +010080 }
Richard Felkl56082e92017-12-20 23:39:53 +010081
82 if(RELEASE_DOCKER.toBoolean())
83 {
84 common.infoMsg("Promoting Docker images")
azvyagintsevd162b912018-07-26 10:52:14 +020085 triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION)
Richard Felkl56082e92017-12-20 23:39:53 +010086 }
87
88 if(RELEASE_GIT.toBoolean())
89 {
90 common.infoMsg("Promoting Git repositories")
Richard Felklc8c5a5a2018-04-19 17:06:30 +020091 triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION)
92
93 }
94 if (EMAIL_NOTIFY.toBoolean()) {
95 emailext(to: NOTIFY_RECIPIENTS,
96 body: NOTIFY_TEXT,
97 subject: "MCP Promotion has been done")
Jakub Josefa63f9862018-01-11 17:58:38 +010098 }
99 }
100 } catch (Throwable e) {
101 // If there was an error or exception thrown, the build failed
102 currentBuild.result = "FAILURE"
103 throw e
Richard Felkl37ee1e32017-12-11 10:01:39 +0100104 }
Richard Felkl37ee1e32017-12-11 10:01:39 +0100105 }
106}