blob: be791d0db4fcb53805b73897d3ed5cd0ad3fb6fb [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 Armstrong93374962023-07-31 16:23:24 -040020String getIam(String func) {
Joey Armstronged161f72023-04-11 13:16:59 -040021 // 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 Armstrong93374962023-07-31 16:23:24 -040029void process(Map args) {
Joey Armstronged161f72023-04-11 13:16:59 -040030 String iam = getIam('process')
Joey Armstrong53cebea2023-07-26 10:35:53 -040031
32 println("** ${iam}: ENTER branch=${args.branch}")
Joey Armstrong93374962023-07-31 16:23:24 -040033 println('args = ' + args)
Joey Armstronged161f72023-04-11 13:16:59 -040034
35 // go install sigs.k8s.io/kind@v0.18.0
Joey Armstrong53cebea2023-07-26 10:35:53 -040036 sh(
Joey Armstrong93374962023-07-31 16:23:24 -040037 script: './installKind.sh',
38 returnStdout: true
Joey Armstrong53cebea2023-07-26 10:35:53 -040039 )
40
Joey Armstronged161f72023-04-11 13:16:59 -040041 println("** ${iam}: LEAVE")
Joey Armstrong93374962023-07-31 16:23:24 -040042 return
Joey Armstronged161f72023-04-11 13:16:59 -040043}
44
45// -----------------------------------------------------------------------
Joey Armstrong5c494962023-07-25 16:48:48 -040046// TODO: Support native syntax: installKind() { debug:true }
Joey Armstronged161f72023-04-11 13:16:59 -040047// -----------------------------------------------------------------------
Joey Armstrong5c494962023-07-25 16:48:48 -040048/*
Joey Armstronged161f72023-04-11 13:16:59 -040049Boolean call\
50 (
Joey Armstrong41feb7c2023-04-14 11:28:04 -040051 // def self, // jenkins env object for access to primitives like echo()
Joey Armstrongea632132023-04-13 13:09:23 -040052 Closure body // jenkins closure attached to the call iam() {closure}
Joey Armstronged161f72023-04-11 13:16:59 -040053 )
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 Armstrong5c494962023-07-25 16:48:48 -040059 */
Joey Armstronged161f72023-04-11 13:16:59 -040060
Joey Armstrong5c494962023-07-25 16:48:48 -040061// -----------------------------------------------------------------------
62// -----------------------------------------------------------------------
Joey Armstrong93374962023-07-31 16:23:24 -040063Boolean call(String branch) {
64 String iam = getIam('main')
65 Boolean ans = true
66
Joey Armstronged161f72023-04-11 13:16:59 -040067 println("** ${iam}: ENTER")
68 println("** ${iam}: Debug= is " + config.contains(debug))
69
Joey Armstrong93374962023-07-31 16:23:24 -040070 try {
71 // Will be passed in eventually
72 Map config = [debug :false, branch:branch]
Joey Armstronged161f72023-04-11 13:16:59 -040073 process(config)
74 }
Joey Armstrong93374962023-07-31 16:23:24 -040075 /*
Joey Armstronged161f72023-04-11 13:16:59 -040076 catch (Exception err)
77 {
78 println("** ${iam}: EXCEPTION ${err}")
79 throw err
80 }
Joey Armstrong93374962023-07-31 16:23:24 -040081*/
82 finally {
Joey Armstronged161f72023-04-11 13:16:59 -040083 println("** ${iam}: LEAVE")
84 }
Joey Armstrong93374962023-07-31 16:23:24 -040085
86 return(ans)
Joey Armstronged161f72023-04-11 13:16:59 -040087}
88
89// [EOF]