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 | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 20 | String getIam(String func) |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 21 | { |
| 22 | // Cannot rely on a stack trace due to jenkins manipulation |
| 23 | String src = 'vars/installKind.groovy' |
| 24 | String iam = [src, func].join('::') |
| 25 | return iam |
| 26 | } |
| 27 | |
| 28 | // ----------------------------------------------------------------------- |
| 29 | // ----------------------------------------------------------------------- |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 30 | def process(Map args) |
| 31 | { |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 32 | String iam = getIam('process') |
| 33 | println("** ${iam}: ENTER") |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 34 | println("args = " + args) |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 35 | |
| 36 | // go install sigs.k8s.io/kind@v0.18.0 |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 37 | sh('./installKind.sh') |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 38 | println("** ${iam}: LEAVE") |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 39 | return |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | // ----------------------------------------------------------------------- |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 43 | // TODO: Support native syntax: installKind() { debug:true } |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 44 | // ----------------------------------------------------------------------- |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 45 | /* |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 46 | Boolean call\ |
| 47 | ( |
Joey Armstrong | 41feb7c | 2023-04-14 11:28:04 -0400 | [diff] [blame] | 48 | // def self, // jenkins env object for access to primitives like echo() |
Joey Armstrong | ea63213 | 2023-04-13 13:09:23 -0400 | [diff] [blame] | 49 | Closure body // jenkins closure attached to the call iam() {closure} |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 50 | ) |
| 51 | { |
| 52 | Map config = [:] // propogate block parameters |
| 53 | body.resolveStrategy = Closure.DELEGATE_FIRST |
| 54 | body.delegate = config // make parameters visible down below |
| 55 | body() |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 56 | */ |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 57 | |
Joey Armstrong | 5c49496 | 2023-07-25 16:48:48 -0400 | [diff] [blame^] | 58 | // ----------------------------------------------------------------------- |
| 59 | // ----------------------------------------------------------------------- |
| 60 | def call(String branch) |
| 61 | { |
Joey Armstrong | ed161f7 | 2023-04-11 13:16:59 -0400 | [diff] [blame] | 62 | String iam = getIam('main') |
| 63 | println("** ${iam}: ENTER") |
| 64 | println("** ${iam}: Debug= is " + config.contains(debug)) |
| 65 | |
| 66 | try |
| 67 | { |
| 68 | process(config) |
| 69 | } |
| 70 | catch (Exception err) |
| 71 | { |
| 72 | println("** ${iam}: EXCEPTION ${err}") |
| 73 | throw err |
| 74 | } |
| 75 | finally |
| 76 | { |
| 77 | println("** ${iam}: LEAVE") |
| 78 | } |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | // [EOF] |