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 | * |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 23 | */ |
| 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: [ |
| 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 Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 42 | def triggerDockerMirrorJob(dockerCredentials, dockerRegistryUrl, targetTag, imageList) { |
Richard Felkl | 55175f5 | 2017-12-20 14:53:41 +0100 | [diff] [blame] | 43 | build job: "docker-images-mirror", parameters: [ |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 44 | [$class: 'StringParameterValue', name: 'TARGET_REGISTRY_CREDENTIALS_ID', value: dockerCredentials], |
| 45 | [$class: 'StringParameterValue', name: 'REGISTRY_URL', value: dockerRegistryUrl], |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 46 | [$class: 'StringParameterValue', name: 'IMAGE_TAG', value: targetTag], |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 47 | [$class: 'StringParameterValue', name: 'IMAGE_LIST', value: imageList] |
| 48 | ] |
| 49 | } |
| 50 | |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 51 | def 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 Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 58 | def triggerGitTagJob(gitRepoList, gitCredentials, tag) { |
Richard Felkl | d16bd48 | 2018-04-24 20:04:28 +0200 | [diff] [blame] | 59 | build job: "tag-git-repos-stable", parameters: [ |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 60 | [$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 Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 64 | } |
Richard Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 65 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 66 | timeout(time: 12, unit: 'HOURS') { |
| 67 | node() { |
| 68 | try { |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 69 | 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 Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 74 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 75 | |
| 76 | if(RELEASE_DEB_MIRRORS.toBoolean()){ |
| 77 | common.infoMsg("Promoting Debmirrors") |
| 78 | triggerMirrorRepoJob(SOURCE_REVISION, TARGET_REVISION) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 79 | } |
Richard Felkl | 56082e9 | 2017-12-20 23:39:53 +0100 | [diff] [blame] | 80 | |
| 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 Felkl | c8c5a5a | 2018-04-19 17:06:30 +0200 | [diff] [blame] | 90 | 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 Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 97 | } |
| 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 Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 103 | } |
Richard Felkl | 37ee1e3 | 2017-12-11 10:01:39 +0100 | [diff] [blame] | 104 | } |
| 105 | } |