blob: 24d2ad7a31af5d445be3d77b42f72c2ba79a4e62 [file] [log] [blame]
Matteo Scandolo67842812021-07-13 16:52:13 -07001// stops all the kail processes created by startComponentsLog
2
3def call(Map config) {
4
5 def defaultConfig = [
6 logsDir: "$WORKSPACE/logs",
7 compress: false, // wether to compress the logs in a tgz file
8 ]
9
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070010 if (!config) {
11 config = [:]
12 }
13
14 def cfg = defaultConfig + config
15
Matteo Scandolo67842812021-07-13 16:52:13 -070016 def tag = "jenkins-"
17 println "Stopping all kail logging process"
18 sh """
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070019 P_IDS="\$(ps e -ww -A | grep "_TAG=jenkins-kail" | grep -v grep | awk '{print \$1}')"
20 if [ -n "\$P_IDS" ]; then
21 for P_ID in \$P_IDS; do
22 kill -9 \$P_ID
Matteo Scandolo67842812021-07-13 16:52:13 -070023 done
24 fi
25 """
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070026 if (cfg.compress) {
Matteo Scandolo67842812021-07-13 16:52:13 -070027 sh """
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070028 tar czf ${cfg.logsDir}/combined.tgz *
Matteo Scandolo67842812021-07-13 16:52:13 -070029 rm *.log
30 """
31
32 }
33}