blob: f3402aa23204dd6abed409366153a37592169a37 [file] [log] [blame]
Joey Armstronged161f72023-04-11 13:16:59 -04001#!/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 Armstrong5c494962023-07-25 16:48:48 -040020String getIam(String func)
Joey Armstronged161f72023-04-11 13:16:59 -040021{
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 Armstrong5c494962023-07-25 16:48:48 -040030def process(Map args)
31{
Joey Armstronged161f72023-04-11 13:16:59 -040032 String iam = getIam('process')
33 println("** ${iam}: ENTER")
Joey Armstrong5c494962023-07-25 16:48:48 -040034 println("args = " + args)
Joey Armstronged161f72023-04-11 13:16:59 -040035
36 // go install sigs.k8s.io/kind@v0.18.0
Joey Armstrong5c494962023-07-25 16:48:48 -040037 sh('./installKind.sh')
Joey Armstronged161f72023-04-11 13:16:59 -040038 println("** ${iam}: LEAVE")
Joey Armstrong5c494962023-07-25 16:48:48 -040039 return
Joey Armstronged161f72023-04-11 13:16:59 -040040}
41
42// -----------------------------------------------------------------------
Joey Armstrong5c494962023-07-25 16:48:48 -040043// TODO: Support native syntax: installKind() { debug:true }
Joey Armstronged161f72023-04-11 13:16:59 -040044// -----------------------------------------------------------------------
Joey Armstrong5c494962023-07-25 16:48:48 -040045/*
Joey Armstronged161f72023-04-11 13:16:59 -040046Boolean call\
47 (
Joey Armstrong41feb7c2023-04-14 11:28:04 -040048 // def self, // jenkins env object for access to primitives like echo()
Joey Armstrongea632132023-04-13 13:09:23 -040049 Closure body // jenkins closure attached to the call iam() {closure}
Joey Armstronged161f72023-04-11 13:16:59 -040050 )
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 Armstrong5c494962023-07-25 16:48:48 -040056 */
Joey Armstronged161f72023-04-11 13:16:59 -040057
Joey Armstrong5c494962023-07-25 16:48:48 -040058// -----------------------------------------------------------------------
59// -----------------------------------------------------------------------
60def call(String branch)
61{
Joey Armstronged161f72023-04-11 13:16:59 -040062 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]