Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 1 | // stops all the kail processes created by startComponentsLog |
| 2 | |
| 3 | def 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 Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame^] | 10 | if (!config) { |
| 11 | config = [:] |
| 12 | } |
| 13 | |
| 14 | def cfg = defaultConfig + config |
| 15 | |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 16 | def tag = "jenkins-" |
| 17 | println "Stopping all kail logging process" |
| 18 | sh """ |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame^] | 19 | 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 Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 23 | done |
| 24 | fi |
| 25 | """ |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame^] | 26 | if (cfg.compress) { |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 27 | sh """ |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame^] | 28 | tar czf ${cfg.logsDir}/combined.tgz * |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 29 | rm *.log |
| 30 | """ |
| 31 | |
| 32 | } |
| 33 | } |