blob: 8af3fbea9e8cdb08fb1ccdad9b593d2e5f583d09 [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
Richard Felkl56082e92017-12-20 23:39:53 +010042def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList) {
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],
Richard Felkl37ee1e32017-12-11 10:01:39 +010047 [$class: 'StringParameterValue', name: 'IMAGE_LIST', value: imageList]
48 ]
49}
50
Richard Felkl56082e92017-12-20 23:39:53 +010051def triggerMirrorRepoJob(snapshotId, snapshotName) {
52 build job: "mirror-snapshot-name-all", parameters: [
53 [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName],
54 [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId]
55 ]
56}
57
Richard Felklc8c5a5a2018-04-19 17:06:30 +020058def triggerGitTagJob(gitRepoList, gitCredentials, tag) {
Richard Felkld16bd482018-04-24 20:04:28 +020059 build job: "tag-git-repos-stable", parameters: [
Richard Felklc8c5a5a2018-04-19 17:06:30 +020060 [$class: 'StringParameterValue', name: 'GIT_REPO_LIST', value: gitRepoList],
61 [$class: 'StringParameterValue', name: 'GIT_CREDENTIALS', value: gitCredentials],
62 [$class: 'StringParameterValue', name: 'TAG', value: tag]
63 ]
Richard Felkl37ee1e32017-12-11 10:01:39 +010064}
Richard Felklc8c5a5a2018-04-19 17:06:30 +020065
Jakub Josefa63f9862018-01-11 17:58:38 +010066timeout(time: 12, unit: 'HOURS') {
67 node() {
68 try {
Richard Felkl56082e92017-12-20 23:39:53 +010069 stage("Promote"){
70 if(RELEASE_APTLY.toBoolean())
71 {
72 common.infoMsg("Promoting Aptly")
73 triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}")
Richard Felkl37ee1e32017-12-11 10:01:39 +010074 }
Richard Felkl56082e92017-12-20 23:39:53 +010075
76 if(RELEASE_DEB_MIRRORS.toBoolean()){
77 common.infoMsg("Promoting Debmirrors")
78 triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION)
Jakub Josefa63f9862018-01-11 17:58:38 +010079 }
Richard Felkl56082e92017-12-20 23:39:53 +010080
81 if(RELEASE_DOCKER.toBoolean())
82 {
83 common.infoMsg("Promoting Docker images")
84 triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES)
85 }
86
87 if(RELEASE_GIT.toBoolean())
88 {
89 common.infoMsg("Promoting Git repositories")
Richard Felklc8c5a5a2018-04-19 17:06:30 +020090 triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION)
91
92 }
93 if (EMAIL_NOTIFY.toBoolean()) {
94 emailext(to: NOTIFY_RECIPIENTS,
95 body: NOTIFY_TEXT,
96 subject: "MCP Promotion has been done")
Jakub Josefa63f9862018-01-11 17:58:38 +010097 }
98 }
99 } catch (Throwable e) {
100 // If there was an error or exception thrown, the build failed
101 currentBuild.result = "FAILURE"
102 throw e
Richard Felkl37ee1e32017-12-11 10:01:39 +0100103 }
Richard Felkl37ee1e32017-12-11 10:01:39 +0100104 }
105}