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 |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 16 | // Combines docker-publish, deploy and test pipelines into one job that can be triggered by a GitHub PR merge |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 17 | |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 18 | |
| 19 | pipeline { |
| 20 | |
| 21 | agent { |
| 22 | label "${params.buildNode}" |
| 23 | } |
| 24 | |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 25 | stages { |
| 26 | stage('Build and Publish') { |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 27 | steps { |
Jeremy Ronquillo | d91e308 | 2020-04-09 11:32:41 -0700 | [diff] [blame] | 28 | script { |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 29 | build_job_name = "docker-publish-github_$repoName" |
| 30 | if ("${repoName}" == "spgw"){ |
| 31 | build_job_name = "aether-member-only-jobs/" + build_job_name |
| 32 | } |
Jeremy Ronquillo | d91e308 | 2020-04-09 11:32:41 -0700 | [diff] [blame] | 33 | abbreviated_commit_hash = commitHash.substring(0, 7) |
Jeremy Ronquillo | 6e42f8c | 2020-04-27 14:13:51 -0700 | [diff] [blame] | 34 | tags_to_build = [ "${branchName}-latest", |
| 35 | "${branchName}-${abbreviated_commit_hash}"] |
| 36 | tags_to_build.each { tag -> |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 37 | build job: "${build_job_name}", parameters: [ |
Jeremy Ronquillo | 6e42f8c | 2020-04-27 14:13:51 -0700 | [diff] [blame] | 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 Ronquillo | d91e308 | 2020-04-09 11:32:41 -0700 | [diff] [blame] | 44 | } |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | |
You Wang | 2a8a91b | 2020-06-15 13:34:22 -0700 | [diff] [blame] | 48 | stage ("Prepare OMEC deployment"){ |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 49 | 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 Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 53 | 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 Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 54 | spgwc_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/spgw/tags/' | jq '.results[] | select(.name | contains("${spgwBranchName}")).name' | head -1 | tr -d \\\"""" |
You Wang | e1cbba2 | 2020-06-15 21:16:14 -0700 | [diff] [blame] | 55 | 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 \\\"""" |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 56 | zmqiface_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 \\\"""" |
| 57 | pfcpiface_tag = sh returnStdout: true, script: """curl -s 'https://registry.hub.docker.com/v2/repositories/omecproject/upf-epc-pfcpiface/tags/' | jq '.results[] | select(.name | contains("${upfBranchName}")).name' | head -1 | tr -d \\\"""" |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 58 | |
| 59 | hssdb_image = "omecproject/c3po-hssdb:"+hssdb_tag |
| 60 | hss_image = "omecproject/c3po-hss:"+hss_tag |
| 61 | mme_image = "omecproject/nucleus:"+mme_tag |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 62 | spgwc_image = "omecproject/spgw:"+spgwc_tag |
You Wang | e1cbba2 | 2020-06-15 21:16:14 -0700 | [diff] [blame] | 63 | bess_image = "omecproject/upf-epc-bess:"+bess_tag |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 64 | zmqiface_image = "omecproject/upf-epc-cpiface:"+zmqiface_tag |
| 65 | pfcpiface_image = "omecproject/upf-epc-pfcpiface:"+pfcpiface_tag |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 66 | |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 67 | switch("${params.repoName}") { |
| 68 | case "c3po": |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 69 | hssdb_image = "${params.registry}/c3po-hssdb:${branchName}-${abbreviated_commit_hash}" |
| 70 | hss_image = "${params.registry}/c3po-hss:${branchName}-${abbreviated_commit_hash}" |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 71 | break |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 72 | case "spgw": |
| 73 | spgwc_image = "${params.registry}/spgw:${branchName}-${abbreviated_commit_hash}" |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 74 | break |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 75 | case "Nucleus": |
| 76 | mme_image = "${params.registry}/nucleus:${branchName}-${abbreviated_commit_hash}" |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 77 | break |
You Wang | e1cbba2 | 2020-06-15 21:16:14 -0700 | [diff] [blame] | 78 | case "upf-epc": |
| 79 | bess_image = "${params.registry}/upf-epc-bess:${branchName}-${abbreviated_commit_hash}" |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 80 | zmqiface_image = "${params.registry}/upf-epc-cpiface:${branchName}-${abbreviated_commit_hash}" |
| 81 | pfcpiface_image = "${params.registry}/upf-epc-pfcpiface:${branchName}-${abbreviated_commit_hash}" |
You Wang | e1cbba2 | 2020-06-15 21:16:14 -0700 | [diff] [blame] | 82 | break |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 83 | } |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 84 | echo "Using hssdb image: ${hssdb_image}" |
| 85 | echo "Using hss image: ${hss_image}" |
| 86 | echo "Using mme image: ${mme_image}" |
| 87 | echo "Using spgwc image: ${spgwc_image}" |
You Wang | e1cbba2 | 2020-06-15 21:16:14 -0700 | [diff] [blame] | 88 | echo "Using bess image: ${bess_image}" |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 89 | echo "Using zmqiface image: ${zmqiface_image}" |
| 90 | echo "Using pfcpiface image: ${pfcpiface_image}" |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 91 | } |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 92 | } |
| 93 | } |
| 94 | |
You Wang | 2a8a91b | 2020-06-15 13:34:22 -0700 | [diff] [blame] | 95 | stage ("Deploy and Test"){ |
| 96 | options { |
| 97 | lock(resource: 'aether-dev-cluster') |
| 98 | } |
| 99 | |
| 100 | stages { |
| 101 | stage ("Deploy OMEC"){ |
| 102 | steps { |
| 103 | build job: "omec_deploy_dev", parameters: [ |
| 104 | string(name: 'hssdbImage', value: "${hssdb_image.trim()}"), |
| 105 | string(name: 'hssImage', value: "${hss_image.trim()}"), |
| 106 | string(name: 'mmeImage', value: "${mme_image.trim()}"), |
| 107 | string(name: 'spgwcImage', value: "${spgwc_image.trim()}"), |
You Wang | e1cbba2 | 2020-06-15 21:16:14 -0700 | [diff] [blame] | 108 | string(name: 'bessImage', value: "${bess_image.trim()}"), |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 109 | string(name: 'zmqifaceImage', value: "${zmqiface_image.trim()}"), |
| 110 | string(name: 'pfcpifaceImage', value: "${pfcpiface_image.trim()}"), |
You Wang | 2a8a91b | 2020-06-15 13:34:22 -0700 | [diff] [blame] | 111 | ] |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | stage ("Run NG40 Tests"){ |
| 116 | steps { |
| 117 | build job: "omec_ng40-test_dev" |
| 118 | } |
| 119 | } |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | } |
| 123 | post { |
| 124 | failure { |
| 125 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false]) |
| 126 | } |
| 127 | } |
| 128 | } |