You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 1 | // Copyright 2020-present Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // omec-postmerge.groovy |
| 16 | // Combines docker-publish and deploy-staging pipelines into one job that can be triggered by a GitHub PR merge |
| 17 | |
| 18 | def hssdb_tag = "" |
| 19 | def hss_tag = "" |
| 20 | def mme_tag = "" |
| 21 | def spgwc_tag = "" |
| 22 | def spgwu_tag = "" |
| 23 | |
| 24 | pipeline { |
| 25 | |
| 26 | agent { |
| 27 | label "${params.buildNode}" |
| 28 | } |
| 29 | |
| 30 | stages { |
| 31 | |
| 32 | stage('Publish') { |
| 33 | steps { |
| 34 | build job: "docker-publish-github_$repoName", parameters: [ |
| 35 | string(name: 'gitUrl', value: "${repoUrl}"), |
| 36 | string(name: 'gitRef', value: "${branchName}"), |
| 37 | string(name: 'branchName', value: "${branchName}-${commitHash}"), |
| 38 | string(name: 'projectName', value: "${repoName}"), |
| 39 | ] |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | stage('Deploy') { |
| 44 | steps { |
| 45 | script { |
| 46 | hssdb_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/c3po-hssdb/tags/' | jq '.results[] | select(.name | contains("${c3poBranchName}")).name' | head -1 | tr -d \\\"""" |
| 47 | hss_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/c3po-hss/tags/' | jq '.results[] | select(.name | contains("${c3poBranchName}")).name' | head -1 | tr -d \\\"""" |
| 48 | mme_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/openmme/tags/' | jq '.results[] | select(.name | contains("${openmmeBranchName}")).name' | head -1 | tr -d \\\"""" |
| 49 | spgwc_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/ngic-cp/tags/' | jq '.results[] | select(.name | contains("${ngicBranchName}")).name' | head -1 | tr -d \\\"""" |
| 50 | spgwu_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/ngic-dp/tags/' | jq '.results[] | select(.name | contains("${ngicBranchName}")).name' | head -1 | tr -d \\\"""" |
| 51 | switch("${params.repoName}") { |
| 52 | case "c3po": |
| 53 | hssdb_tag = "${branchName}-${commitHash}" |
| 54 | hss_tag = "${branchName}-${commitHash}" |
| 55 | break |
| 56 | case "ngic-rtc": |
| 57 | spgwc_tag = "${branchName}-${commitHash}" |
| 58 | spgwu_tag = "${branchName}-${commitHash}" |
| 59 | break |
| 60 | case "openmme": |
| 61 | mme_tag = "${branchName}-${commitHash}" |
| 62 | break |
| 63 | } |
| 64 | } |
| 65 | build job: "omec-deploy-staging", parameters: [ |
| 66 | string(name: 'hssdb_tag', value: "${hssdb_tag}"), |
| 67 | string(name: 'mme_tag', value: "${hss_tag}"), |
| 68 | string(name: 'hss_tag', value: "${mme_tag}"), |
| 69 | string(name: 'spgwc_tag', value: "${spgwc_tag}"), |
| 70 | string(name: 'spgwu_tag', value: "${spgwu_tag}"), |
| 71 | ] |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | post { |
| 76 | failure { |
| 77 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false]) |
| 78 | } |
| 79 | } |
| 80 | } |