blob: ea528ed842e330eee8c6bcb1378c2d136a7d8b95 [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 *
azvyagintsev3280a0c2018-07-31 08:44:43 +020023*/
Richard Felkl37ee1e32017-12-11 10:01:39 +010024
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: [
azvyagintsev3280a0c2018-07-31 08:44:43 +020030 [$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]
Richard Felkl37ee1e32017-12-11 10:01:39 +010039 ]
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: [
azvyagintsev3280a0c2018-07-31 08:44:43 +020044 [$class: 'StringParameterValue', name: 'TARGET_REGISTRY_CREDENTIALS_ID', value: dockerCredentials],
45 [$class: 'StringParameterValue', name: 'REGISTRY_URL', value: dockerRegistryUrl],
46 [$class: 'StringParameterValue', name: 'IMAGE_TAG', value: targetTag],
47 [$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: [
azvyagintsev3280a0c2018-07-31 08:44:43 +020054 [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName],
55 [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId]
Richard Felkl56082e92017-12-20 23:39:53 +010056 ]
57}
58
azvyagintsev3280a0c2018-07-31 08:44:43 +020059def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) {
Richard Felkld16bd482018-04-24 20:04:28 +020060 build job: "tag-git-repos-stable", parameters: [
azvyagintsev3280a0c2018-07-31 08:44:43 +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 [$class: 'StringParameterValue', name: 'SOURCE_TAG', value: sourceTag]
Richard Felklc8c5a5a2018-04-19 17:06:30 +020065 ]
Richard Felkl37ee1e32017-12-11 10:01:39 +010066}
Richard Felklc8c5a5a2018-04-19 17:06:30 +020067
Jakub Josefa63f9862018-01-11 17:58:38 +010068timeout(time: 12, unit: 'HOURS') {
azvyagintsev3280a0c2018-07-31 08:44:43 +020069 node() {
70 try {
71 stage("Promote"){
72 if(RELEASE_APTLY.toBoolean())
73 {
74 common.infoMsg("Promoting Aptly")
75 triggerAptlyPromoteJob(APTLY_URL, 'all', false, true, 'all', false, "(.*)/${SOURCE_REVISION}", APTLY_STORAGES, "{0}/${TARGET_REVISION}")
76 }
Richard Felkl56082e92017-12-20 23:39:53 +010077
azvyagintsev3280a0c2018-07-31 08:44:43 +020078 if(RELEASE_DEB_MIRRORS.toBoolean()){
79 common.infoMsg("Promoting Debmirrors")
80 triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION)
81 }
Richard Felkl56082e92017-12-20 23:39:53 +010082
azvyagintsev3280a0c2018-07-31 08:44:43 +020083 if(RELEASE_DOCKER.toBoolean())
84 {
85 common.infoMsg("Promoting Docker images")
86 triggerDockerMirrorJob(DOCKER_CREDENTIALS, DOCKER_URL, TARGET_REVISION, DOCKER_IMAGES, SOURCE_REVISION)
87 }
Richard Felkl56082e92017-12-20 23:39:53 +010088
azvyagintsev3280a0c2018-07-31 08:44:43 +020089 if(RELEASE_GIT.toBoolean())
90 {
91 common.infoMsg("Promoting Git repositories")
92 triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION)
Richard Felklc8c5a5a2018-04-19 17:06:30 +020093
azvyagintsev3280a0c2018-07-31 08:44:43 +020094 }
95 if (EMAIL_NOTIFY.toBoolean()) {
96 emailext(to: NOTIFY_RECIPIENTS,
97 body: NOTIFY_TEXT,
98 subject: "MCP Promotion has been done")
99 }
100 }
101 } catch (Throwable e) {
Jakub Josefa63f9862018-01-11 17:58:38 +0100102 // If there was an error or exception thrown, the build failed
103 currentBuild.result = "FAILURE"
104 throw e
azvyagintsev3280a0c2018-07-31 08:44:43 +0200105 }
Richard Felkl37ee1e32017-12-11 10:01:39 +0100106 }
azvyagintsev3280a0c2018-07-31 08:44:43 +0200107 }