Joey Armstrong | 775a20f | 2022-12-02 12:55:43 -0500 | [diff] [blame] | 1 | // Copyright 2020-2023 Open Networking Foundation (ONF) and the ONF Contributors |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 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 | |
You Wang | d78fec6 | 2021-02-08 16:07:46 -0800 | [diff] [blame] | 15 | // Builds and publishes OMEC docker images. Triggered by GitHub PR merge. |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 16 | |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 17 | |
| 18 | pipeline { |
| 19 | |
| 20 | agent { |
| 21 | label "${params.buildNode}" |
| 22 | } |
| 23 | |
You Wang | 4023945 | 2020-06-11 20:17:15 -0700 | [diff] [blame] | 24 | stages { |
| 25 | stage('Build and Publish') { |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 26 | steps { |
Jeremy Ronquillo | d91e308 | 2020-04-09 11:32:41 -0700 | [diff] [blame] | 27 | script { |
You Wang | 425d49f | 2020-07-29 21:43:28 -0700 | [diff] [blame] | 28 | build_job_name = "docker-publish-github_$repoName" |
| 29 | if ("${repoName}" == "spgw"){ |
| 30 | build_job_name = "aether-member-only-jobs/" + build_job_name |
| 31 | } |
Jeremy Ronquillo | d91e308 | 2020-04-09 11:32:41 -0700 | [diff] [blame] | 32 | abbreviated_commit_hash = commitHash.substring(0, 7) |
Jeremy Ronquillo | 6e42f8c | 2020-04-27 14:13:51 -0700 | [diff] [blame] | 33 | tags_to_build = [ "${branchName}-latest", |
You Wang | 7673e48 | 2020-09-18 16:33:34 -0700 | [diff] [blame] | 34 | "${branchName}-${abbreviated_commit_hash}" ] |
| 35 | env_vars = [ "", "" ] |
| 36 | if ("${repoName}" == "upf-epc"){ |
| 37 | tags_to_build += [ "${branchName}-latest-ivybridge", |
| 38 | "${branchName}-${abbreviated_commit_hash}-ivybridge" ] |
| 39 | env_vars = [ "CPU=haswell", "CPU=haswell", "CPU=ivybridge", "CPU=ivybridge" ] |
Jeremy Ronquillo | 6e42f8c | 2020-04-27 14:13:51 -0700 | [diff] [blame] | 40 | } |
You Wang | 7673e48 | 2020-09-18 16:33:34 -0700 | [diff] [blame] | 41 | def builds = [:] |
| 42 | for(i = 0; i < tags_to_build.size(); i += 1) { |
| 43 | def tag_to_build = tags_to_build[i] |
| 44 | def env_var = env_vars[i] |
| 45 | builds["${build_job_name}${i}"] = { |
| 46 | build job: "${build_job_name}", parameters: [ |
| 47 | string(name: 'gitUrl', value: "${repoUrl}"), |
| 48 | string(name: 'gitRef', value: "${branchName}"), |
| 49 | string(name: 'branchName', value: tag_to_build), |
| 50 | string(name: 'projectName', value: "${repoName}"), |
| 51 | string(name: 'extraEnvironmentVars', value: env_var), |
| 52 | ] |
| 53 | } |
| 54 | } |
| 55 | parallel builds |
Jeremy Ronquillo | d91e308 | 2020-04-09 11:32:41 -0700 | [diff] [blame] | 56 | } |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 57 | } |
| 58 | } |
You Wang | 5c15a7a | 2020-04-02 11:24:33 -0700 | [diff] [blame] | 59 | } |
| 60 | post { |
| 61 | failure { |
| 62 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false]) |
| 63 | } |
| 64 | } |
| 65 | } |