Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | // ----------------------------------------------------------------------- |
| 3 | // Copyright 2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | // ----------------------------------------------------------------------- |
| 17 | |
| 18 | // ----------------------------------------------------------------------- |
| 19 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 20 | String getIam(String func) { |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 21 | // Cannot rely on a stack trace due to jenkins manipulation |
| 22 | String src = 'vars/installKind.groovy' |
| 23 | String iam = [src, func].join('::') |
| 24 | return iam |
| 25 | } |
| 26 | |
| 27 | // ----------------------------------------------------------------------- |
| 28 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 29 | void process(Map args) { |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 30 | String iam = getIam('process') |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 31 | |
| 32 | println("** ${iam}: ENTER branch=${args.branch}") |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 33 | println('args = ' + args) |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 34 | |
| 35 | // go install sigs.k8s.io/kind@v0.18.0 |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 36 | sh( |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 37 | script: './installKind.sh', |
| 38 | returnStdout: true |
Joey Armstrong | 53cebea | 2023-07-26 10:35:53 -0400 | [diff] [blame] | 39 | ) |
| 40 | |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 41 | println("** ${iam}: LEAVE") |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 42 | return |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | // ----------------------------------------------------------------------- |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame] | 46 | // TODO: Support native syntax: installKind() { debug:true } |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 47 | // ----------------------------------------------------------------------- |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame] | 48 | /* |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 49 | Boolean call\ |
| 50 | ( |
Joey Armstrong | 41feb7c | 2023-04-14 11:28:04 -0400 | [diff] [blame] | 51 | // def self, // jenkins env object for access to primitives like echo() |
Joey Armstrong | ea63213 | 2023-04-13 13:09:23 -0400 | [diff] [blame] | 52 | Closure body // jenkins closure attached to the call iam() {closure} |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 53 | ) |
| 54 | { |
| 55 | Map config = [:] // propogate block parameters |
| 56 | body.resolveStrategy = Closure.DELEGATE_FIRST |
| 57 | body.delegate = config // make parameters visible down below |
| 58 | body() |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame] | 59 | */ |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 60 | |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame] | 61 | // ----------------------------------------------------------------------- |
| 62 | // ----------------------------------------------------------------------- |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 63 | Boolean call(String branch) { |
| 64 | String iam = getIam('main') |
| 65 | Boolean ans = true |
| 66 | |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 67 | println("** ${iam}: ENTER") |
| 68 | println("** ${iam}: Debug= is " + config.contains(debug)) |
| 69 | |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 70 | try { |
| 71 | // Will be passed in eventually |
| 72 | Map config = [debug :false, branch:branch] |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 73 | process(config) |
| 74 | } |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 75 | /* |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 76 | catch (Exception err) |
| 77 | { |
| 78 | println("** ${iam}: EXCEPTION ${err}") |
| 79 | throw err |
| 80 | } |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 81 | */ |
| 82 | finally { |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 83 | println("** ${iam}: LEAVE") |
| 84 | } |
Joey Armstrong | 9337496 | 2023-07-31 16:23:24 -0400 | [diff] [blame^] | 85 | |
| 86 | return(ans) |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | // [EOF] |