blob: bf6fa9a4f21c89ce784a1b0c35a4f13103610ba3 [file] [log] [blame]
Joey Armstrongb9a6f122023-08-24 22:00:04 -04001#!/usr/bin/env groovy
2// -----------------------------------------------------------------------
3// Copyright 2021-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// Install the voltctl command by branch name "voltha-xx"
18// -----------------------------------------------------------------------
19
20// -----------------------------------------------------------------------
21// -----------------------------------------------------------------------
22String getIam(String func) {
23 // Cannot rely on a stack trace due to jenkins manipulation
24 String src = 'vars/pgrep_proc.groovy'
25 String iam = [src, func].join('::')
26 return iam
27}
28
29// -----------------------------------------------------------------------
30// -----------------------------------------------------------------------
31Boolean process(String proc) {
32 String iam = getIam('process')
33 Boolean ans = true
34
35 println("** ${iam}: ENTER")
36
37 String cmdFull = "pgrep --list-full '${proc}'"
38 String cmd = """if [[ \$(pgrep --count "${proc}") -gt 0 ]]; then ${cmdFull}; fi"""
39
40 println(" ** Running: ${cmd}")
41 sh(
42 label : 'pgrep_proc', // jenkins usability: label log entry 'step'
43 script : "${cmd}",
44 )
45
46 println("** ${iam}: LEAVE")
47 return(ans)
48}
49
50// -----------------------------------------------------------------------
51// Install: Jenkins/groovy callback for installing the kind command.
52// o Paramter branch is passed but not yet used.
53// o Installer should be release friendly and checkout a frozen version
54// -----------------------------------------------------------------------
55def call(String proc) {
56 String iam = getIam('main')
57
58 println("** ${iam}: ENTER")
59
60 try {
61 process(proc)
62 }
63 catch (Exception err) {
64 println("** ${iam}: EXCEPTION ${err}")
65 throw err
66 }
67 finally {
68 println("** ${iam}: LEAVE")
69 }
70 return
71}
72
73// [EOF]