blob: bad532d7c83ed0ed3eb3b8adca371f8a6e7f9cdd [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 options {
26 timeout(time: 2, unit: 'HOURS')
27 }
You Wang5c15a7a2020-04-02 11:24:33 -070028
You Wang40239452020-06-11 20:17:15 -070029 stages {
30 stage('Build and Publish') {
You Wang5c15a7a2020-04-02 11:24:33 -070031 steps {
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070032 script {
33 abbreviated_commit_hash = commitHash.substring(0, 7)
Jeremy Ronquillo6e42f8c2020-04-27 14:13:51 -070034 tags_to_build = [ "${branchName}-latest",
35 "${branchName}-${abbreviated_commit_hash}"]
36 tags_to_build.each { tag ->
37 build job: "docker-publish-github_$repoName", parameters: [
38 string(name: 'gitUrl', value: "${repoUrl}"),
39 string(name: 'gitRef', value: "${branchName}"),
40 string(name: 'branchName', value: "${tag}"),
41 string(name: 'projectName', value: "${repoName}"),
42 ]
43 }
Jeremy Ronquillod91e3082020-04-09 11:32:41 -070044 }
You Wang5c15a7a2020-04-02 11:24:33 -070045 }
46 }
47
You Wang40239452020-06-11 20:17:15 -070048 stage('Deploy OMEC') {
You Wang5c15a7a2020-04-02 11:24:33 -070049 steps {
50 script {
51 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 \\\""""
52 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 -070053 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 -070054 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 \\\""""
55 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 \\\""""
You Wang40239452020-06-11 20:17:15 -070056
57 hssdb_image = "omecproject/c3po-hssdb:"+hssdb_tag
58 hss_image = "omecproject/c3po-hss:"+hss_tag
59 mme_image = "omecproject/nucleus:"+mme_tag
60 spgwc_image = "omecproject/ngic-cp:"+spgwc_tag
61 spgwu_image = "omecproject/ngic-dp:"+spgwu_tag
62
You Wang5c15a7a2020-04-02 11:24:33 -070063 switch("${params.repoName}") {
64 case "c3po":
You Wang40239452020-06-11 20:17:15 -070065 hssdb_image = "${params.registry}/c3po-hssdb:${branchName}-${abbreviated_commit_hash}"
66 hss_image = "${params.registry}/c3po-hss:${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070067 break
68 case "ngic-rtc":
You Wang40239452020-06-11 20:17:15 -070069 spgwc_image = "${params.registry}/ngic-cp:${branchName}-${abbreviated_commit_hash}"
70 spgwu_image = "${params.registry}/ngic-dp:${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070071 break
You Wang40239452020-06-11 20:17:15 -070072 case "Nucleus":
73 mme_image = "${params.registry}/nucleus:${branchName}-${abbreviated_commit_hash}"
You Wang5c15a7a2020-04-02 11:24:33 -070074 break
75 }
You Wang40239452020-06-11 20:17:15 -070076 echo "Using hssdb image: ${hssdb_image}"
77 echo "Using hss image: ${hss_image}"
78 echo "Using mme image: ${mme_image}"
79 echo "Using spgwc image: ${spgwc_image}"
80 echo "Using spgwu image: ${spgwu_image}"
You Wang5c15a7a2020-04-02 11:24:33 -070081 }
You Wang40239452020-06-11 20:17:15 -070082
83 build job: "omec-deploy-dev", parameters: [
84 string(name: 'hssdbImage', value: "${hssdb_image.trim()}"),
85 string(name: 'hssImage', value: "${hss_image.trim()}"),
86 string(name: 'mmeImage', value: "${mme_image.trim()}"),
87 string(name: 'spgwcImage', value: "${spgwc_image.trim()}"),
88 string(name: 'spgwuImage', value: "${spgwu_image.trim()}"),
89 ]
90 }
91 }
92
93 stage ("Run NG40 Tests"){
94 steps {
95 build job: "omec-test-dev"
You Wang5c15a7a2020-04-02 11:24:33 -070096 }
97 }
98 }
99 post {
100 failure {
101 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false])
102 }
103 }
104}