blob: abd983b45897f98b571962fcdfb79ba3b62a79a7 [file] [log] [blame]
You Wang5c15a7a2020-04-02 11:24:33 -07001// 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
18def hssdb_tag = ""
19def hss_tag = ""
20def mme_tag = ""
21def spgwc_tag = ""
22def spgwu_tag = ""
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070023def abbreviated_commit_hash = ""
You Wang5c15a7a2020-04-02 11:24:33 -070024
25pipeline {
26
27 agent {
28 label "${params.buildNode}"
29 }
30
31 stages {
32
33 stage('Publish') {
34 steps {
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070035 script {
36 abbreviated_commit_hash = commitHash.substring(0, 7)
37 }
You Wang5c15a7a2020-04-02 11:24:33 -070038 build job: "docker-publish-github_$repoName", parameters: [
39 string(name: 'gitUrl', value: "${repoUrl}"),
40 string(name: 'gitRef', value: "${branchName}"),
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070041 string(name: 'branchName', value: "${branchName}-${abbreviated_commit_hash}"),
You Wang5c15a7a2020-04-02 11:24:33 -070042 string(name: 'projectName', value: "${repoName}"),
43 ]
44 }
45 }
46
47 stage('Deploy') {
48 steps {
49 script {
50 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 \\\""""
51 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 \\\""""
52 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 \\\""""
53 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 \\\""""
54 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 \\\""""
55 switch("${params.repoName}") {
56 case "c3po":
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070057 hssdb_tag = "${branchName}-${abbreviated_commit_hash}"
58 hss_tag = "${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070059 break
60 case "ngic-rtc":
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070061 spgwc_tag = "${branchName}-${abbreviated_commit_hash}"
62 spgwu_tag = "${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070063 break
64 case "openmme":
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070065 mme_tag = "${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070066 break
67 }
68 }
69 build job: "omec-deploy-staging", parameters: [
70 string(name: 'hssdb_tag', value: "${hssdb_tag}"),
71 string(name: 'mme_tag', value: "${hss_tag}"),
72 string(name: 'hss_tag', value: "${mme_tag}"),
73 string(name: 'spgwc_tag', value: "${spgwc_tag}"),
74 string(name: 'spgwu_tag', value: "${spgwu_tag}"),
75 ]
76 }
77 }
78 }
79 post {
80 failure {
81 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false])
82 }
83 }
84}