blob: acc90c849a06916ba7a316980d39daf3681e553d [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
You Wang40239452020-06-11 20:17:15 -070016// Combines docker-publish, deploy and test pipelines into one job that can be triggered by a GitHub PR merge
You Wang5c15a7a2020-04-02 11:24:33 -070017
You Wang5c15a7a2020-04-02 11:24:33 -070018
19pipeline {
20
21 agent {
22 label "${params.buildNode}"
23 }
24
You Wang40239452020-06-11 20:17:15 -070025 stages {
26 stage('Build and Publish') {
You Wang5c15a7a2020-04-02 11:24:33 -070027 steps {
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070028 script {
29 abbreviated_commit_hash = commitHash.substring(0, 7)
Jeremy Ronquillo6e42f8c2020-04-27 14:13:51 -070030 tags_to_build = [ "${branchName}-latest",
31 "${branchName}-${abbreviated_commit_hash}"]
32 tags_to_build.each { tag ->
33 build job: "docker-publish-github_$repoName", parameters: [
34 string(name: 'gitUrl', value: "${repoUrl}"),
35 string(name: 'gitRef', value: "${branchName}"),
36 string(name: 'branchName', value: "${tag}"),
37 string(name: 'projectName', value: "${repoName}"),
38 ]
39 }
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070040 }
You Wang5c15a7a2020-04-02 11:24:33 -070041 }
42 }
43
You Wang2a8a91b2020-06-15 13:34:22 -070044 stage ("Prepare OMEC deployment"){
You Wang5c15a7a2020-04-02 11:24:33 -070045 steps {
46 script {
47 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 \\\""""
48 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 \\\""""
You Wang40239452020-06-11 20:17:15 -070049 mme_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/nucleus/tags/' | jq '.results[] | select(.name | contains("${nucleusBranchName}")).name' | head -1 | tr -d \\\""""
You Wang5c15a7a2020-04-02 11:24:33 -070050 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 \\\""""
You Wange1cbba22020-06-15 21:16:14 -070051 bess_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/upf-epc-bess/tags/' | jq '.results[] | select(.name | contains("${upfBranchName}")).name' | head -1 | tr -d \\\""""
52 cpiface_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/upf-epc-cpiface/tags/' | jq '.results[] | select(.name | contains("${upfBranchName}")).name' | head -1 | tr -d \\\""""
You Wang40239452020-06-11 20:17:15 -070053
54 hssdb_image = "omecproject/c3po-hssdb:"+hssdb_tag
55 hss_image = "omecproject/c3po-hss:"+hss_tag
56 mme_image = "omecproject/nucleus:"+mme_tag
57 spgwc_image = "omecproject/ngic-cp:"+spgwc_tag
You Wange1cbba22020-06-15 21:16:14 -070058 bess_image = "omecproject/upf-epc-bess:"+bess_tag
59 cpiface_image = "omecproject/upf-epc-cpiface:"+cpiface_tag
You Wang40239452020-06-11 20:17:15 -070060
You Wang5c15a7a2020-04-02 11:24:33 -070061 switch("${params.repoName}") {
62 case "c3po":
You Wang40239452020-06-11 20:17:15 -070063 hssdb_image = "${params.registry}/c3po-hssdb:${branchName}-${abbreviated_commit_hash}"
64 hss_image = "${params.registry}/c3po-hss:${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070065 break
66 case "ngic-rtc":
You Wang40239452020-06-11 20:17:15 -070067 spgwc_image = "${params.registry}/ngic-cp:${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070068 break
You Wang40239452020-06-11 20:17:15 -070069 case "Nucleus":
70 mme_image = "${params.registry}/nucleus:${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070071 break
You Wange1cbba22020-06-15 21:16:14 -070072 case "upf-epc":
73 bess_image = "${params.registry}/upf-epc-bess:${branchName}-${abbreviated_commit_hash}"
74 cpiface_image = "${params.registry}/upf-epc-cpiface:${branchName}-${abbreviated_commit_hash}"
75 break
You Wang5c15a7a2020-04-02 11:24:33 -070076 }
You Wang40239452020-06-11 20:17:15 -070077 echo "Using hssdb image: ${hssdb_image}"
78 echo "Using hss image: ${hss_image}"
79 echo "Using mme image: ${mme_image}"
80 echo "Using spgwc image: ${spgwc_image}"
You Wange1cbba22020-06-15 21:16:14 -070081 echo "Using bess image: ${bess_image}"
82 echo "Using cpiface image: ${cpiface_image}"
You Wang5c15a7a2020-04-02 11:24:33 -070083 }
You Wang40239452020-06-11 20:17:15 -070084 }
85 }
86
You Wang2a8a91b2020-06-15 13:34:22 -070087 stage ("Deploy and Test"){
88 options {
89 lock(resource: 'aether-dev-cluster')
90 }
91
92 stages {
93 stage ("Deploy OMEC"){
94 steps {
95 build job: "omec_deploy_dev", parameters: [
96 string(name: 'hssdbImage', value: "${hssdb_image.trim()}"),
97 string(name: 'hssImage', value: "${hss_image.trim()}"),
98 string(name: 'mmeImage', value: "${mme_image.trim()}"),
99 string(name: 'spgwcImage', value: "${spgwc_image.trim()}"),
You Wange1cbba22020-06-15 21:16:14 -0700100 string(name: 'bessImage', value: "${bess_image.trim()}"),
101 string(name: 'cpifaceImage', value: "${cpiface_image.trim()}"),
You Wang2a8a91b2020-06-15 13:34:22 -0700102 ]
103 }
104 }
105
106 stage ("Run NG40 Tests"){
107 steps {
108 build job: "omec_ng40-test_dev"
109 }
110 }
You Wang5c15a7a2020-04-02 11:24:33 -0700111 }
112 }
113 }
114 post {
115 failure {
116 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false])
117 }
118 }
119}