Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
| 2 | // ----------------------------------------------------------------------- |
Joey Armstrong | 518f357 | 2024-02-11 07:56:25 -0500 | [diff] [blame] | 3 | // Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 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 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 17 | // stops all the kail processes created by startComponentsLog |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 18 | // ----------------------------------------------------------------------- |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 19 | |
| 20 | def 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 Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame] | 27 | if (!config) { |
| 28 | config = [:] |
| 29 | } |
| 30 | |
| 31 | def cfg = defaultConfig + config |
| 32 | |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 33 | def tag = "jenkins-" |
| 34 | println "Stopping all kail logging process" |
| 35 | sh """ |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame] | 36 | 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 Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 40 | done |
| 41 | fi |
| 42 | """ |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame] | 43 | if (cfg.compress) { |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 44 | sh """ |
Matteo Scandolo | 544fa7b | 2021-07-23 11:03:24 -0700 | [diff] [blame] | 45 | pushd ${cfg.logsDir} |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame] | 46 | tar czf ${cfg.logsDir}/combined.tgz * |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 47 | rm *.log |
Matteo Scandolo | 544fa7b | 2021-07-23 11:03:24 -0700 | [diff] [blame] | 48 | popd |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 49 | """ |
| 50 | |
| 51 | } |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | // [EOF] |