Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 1 | /** |
| 2 | * |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 3 | * Promote MCP |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 4 | * |
| 5 | * Expected parameters: |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 6 | * SOURCE_REVISION |
| 7 | * TARGET_REVISION |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 8 | * RELEASE_APTLY |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 9 | * RELEASE_DEB_MIRRORS |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 10 | * 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 Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 19 | * EMAIL_NOTIFY |
| 20 | * NOTIFY_RECIPIENTS |
| 21 | * NOTIFY_TEXT |
| 22 | * |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 23 | */ |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 24 | |
Richard Felkl | 55175f5 | 2017-12-20 14:53:41 +0100 | [diff] [blame] | 25 | common = new com.mirantis.mk.Common() |
| 26 | git = new com.mirantis.mk.Git() |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 27 | |
| 28 | def triggerAptlyPromoteJob(aptlyUrl, components, diffOnly, dumpPublish, packages, recreate, source, storages, target){ |
| 29 | build job: "aptly-promote-all-testing-stable", parameters: [ |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 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] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 39 | ] |
| 40 | } |
| 41 | |
azvyagintsev | d162b91 | 2018-07-26 10:52:14 +0200 | [diff] [blame] | 42 | def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList, sourceImageTag) { |
Richard Felkl | 55175f5 | 2017-12-20 14:53:41 +0100 | [diff] [blame] | 43 | build job: "docker-images-mirror", parameters: [ |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 44 | [$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 Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 49 | ] |
| 50 | } |
| 51 | |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 52 | def triggerMirrorRepoJob(snapshotId, snapshotName) { |
| 53 | build job: "mirror-snapshot-name-all", parameters: [ |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 54 | [$class: 'StringParameterValue', name: 'SNAPSHOT_NAME', value: snapshotName], |
| 55 | [$class: 'StringParameterValue', name: 'SNAPSHOT_ID', value: snapshotId] |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 56 | ] |
| 57 | } |
| 58 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 59 | def triggerGitTagJob(gitRepoList, gitCredentials, tag, sourceTag) { |
Richard Felkl | d16bd48 | 2018-04-24 20:04:28 +0200 | [diff] [blame] | 60 | build job: "tag-git-repos-stable", parameters: [ |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 61 | [$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 Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 65 | ] |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 66 | } |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 67 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 68 | timeout(time: 12, unit: 'HOURS') { |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 69 | 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 Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 77 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 78 | if(RELEASE_DEB_MIRRORS.toBoolean()){ |
| 79 | common.infoMsg("Promoting Debmirrors") |
| 80 | triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION) |
| 81 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 82 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 83 | 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 Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 88 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 89 | if(RELEASE_GIT.toBoolean()) |
| 90 | { |
| 91 | common.infoMsg("Promoting Git repositories") |
| 92 | triggerGitTagJob(GIT_REPO_LIST, GIT_CREDENTIALS, TARGET_REVISION, SOURCE_REVISION) |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 93 | |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 94 | } |
| 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 Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 102 | // If there was an error or exception thrown, the build failed |
| 103 | currentBuild.result = "FAILURE" |
| 104 | throw e |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 105 | } |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 106 | } |
azvyagintsev | 3280a0c | 2018-07-31 08:44:43 +0200 | [diff] [blame^] | 107 | } |