blob: 4fd2cf28343ed21acc2703281782b2c2b3ec2088 [file] [log] [blame]
Joey Armstrongaf679da2023-01-31 14:22:41 -05001#!/usr/bin/env groovy
2// -----------------------------------------------------------------------
Joey Armstrong518f3572024-02-11 07:56:25 -05003// Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrongaf679da2023-01-31 14:22:41 -05004//
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// -----------------------------------------------------------------------
Matteo Scandolo67842812021-07-13 16:52:13 -070017// stops all the kail processes created by startComponentsLog
Joey Armstrongaf679da2023-01-31 14:22:41 -050018// -----------------------------------------------------------------------
Matteo Scandolo67842812021-07-13 16:52:13 -070019
20def call(Map config) {
21
22 def defaultConfig = [
23 logsDir: "$WORKSPACE/logs",
24 compress: false, // wether to compress the logs in a tgz file
25 ]
26
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070027 if (!config) {
28 config = [:]
29 }
30
31 def cfg = defaultConfig + config
32
Matteo Scandolo67842812021-07-13 16:52:13 -070033 def tag = "jenkins-"
34 println "Stopping all kail logging process"
35 sh """
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070036 P_IDS="\$(ps e -ww -A | grep "_TAG=jenkins-kail" | grep -v grep | awk '{print \$1}')"
37 if [ -n "\$P_IDS" ]; then
38 for P_ID in \$P_IDS; do
39 kill -9 \$P_ID
Matteo Scandolo67842812021-07-13 16:52:13 -070040 done
41 fi
42 """
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070043 if (cfg.compress) {
Matteo Scandolo67842812021-07-13 16:52:13 -070044 sh """
Matteo Scandolo544fa7b2021-07-23 11:03:24 -070045 pushd ${cfg.logsDir}
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070046 tar czf ${cfg.logsDir}/combined.tgz *
Matteo Scandolo67842812021-07-13 16:52:13 -070047 rm *.log
Matteo Scandolo544fa7b2021-07-23 11:03:24 -070048 popd
Matteo Scandolo67842812021-07-13 16:52:13 -070049 """
50
51 }
Joey Armstrongaf679da2023-01-31 14:22:41 -050052}
53
54// [EOF]