blob: 6729c37a8d3e7475b0c73ef5168722492fe6adb7 [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 Scandolo544fa7b2021-07-23 11:03:24 -070028 pushd ${cfg.logsDir}
Matteo Scandolo7b64b6d2021-07-15 12:07:02 -070029 tar czf ${cfg.logsDir}/combined.tgz *
Matteo Scandolo67842812021-07-13 16:52:13 -070030 rm *.log
Matteo Scandolo544fa7b2021-07-23 11:03:24 -070031 popd
Matteo Scandolo67842812021-07-13 16:52:13 -070032 """
33
34 }
35}