blob: 724c9ef503aa1924df7594dc9b415e23aa108e20 [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')
Joey Armstrong53cebea2023-07-26 10:35:53 -040033 Boolean ans = true
34
35 println("** ${iam}: ENTER branch=${args.branch}")
Joey Armstrong5c494962023-07-25 16:48:48 -040036 println("args = " + args)
Joey Armstronged161f72023-04-11 13:16:59 -040037
38 // go install sigs.k8s.io/kind@v0.18.0
Joey Armstrong53cebea2023-07-26 10:35:53 -040039 sh(
40 script: './installKind.sh',
41 returnStdout: true
42 )
43
Joey Armstronged161f72023-04-11 13:16:59 -040044 println("** ${iam}: LEAVE")
Joey Armstrong53cebea2023-07-26 10:35:53 -040045 return(ans)
Joey Armstronged161f72023-04-11 13:16:59 -040046}
47
48// -----------------------------------------------------------------------
Joey Armstrong5c494962023-07-25 16:48:48 -040049// TODO: Support native syntax: installKind() { debug:true }
Joey Armstronged161f72023-04-11 13:16:59 -040050// -----------------------------------------------------------------------
Joey Armstrong5c494962023-07-25 16:48:48 -040051/*
Joey Armstronged161f72023-04-11 13:16:59 -040052Boolean call\
53 (
Joey Armstrong41feb7c2023-04-14 11:28:04 -040054 // def self, // jenkins env object for access to primitives like echo()
Joey Armstrongea632132023-04-13 13:09:23 -040055 Closure body // jenkins closure attached to the call iam() {closure}
Joey Armstronged161f72023-04-11 13:16:59 -040056 )
57{
58 Map config = [:] // propogate block parameters
59 body.resolveStrategy = Closure.DELEGATE_FIRST
60 body.delegate = config // make parameters visible down below
61 body()
Joey Armstrong5c494962023-07-25 16:48:48 -040062 */
Joey Armstronged161f72023-04-11 13:16:59 -040063
Joey Armstrong5c494962023-07-25 16:48:48 -040064// -----------------------------------------------------------------------
65// -----------------------------------------------------------------------
66def call(String branch)
67{
Joey Armstronged161f72023-04-11 13:16:59 -040068 String iam = getIam('main')
69 println("** ${iam}: ENTER")
70 println("** ${iam}: Debug= is " + config.contains(debug))
71
72 try
73 {
Joey Armstrong53cebea2023-07-26 10:35:53 -040074 // Will be passed in eventually
75 Map config = [debug :false, branch:branch]
Joey Armstronged161f72023-04-11 13:16:59 -040076 process(config)
77 }
78 catch (Exception err)
79 {
80 println("** ${iam}: EXCEPTION ${err}")
81 throw err
82 }
83 finally
84 {
85 println("** ${iam}: LEAVE")
86 }
87 return
88}
89
90// [EOF]