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 | 544fa7b | 2021-07-23 11:03:24 -0700 | [diff] [blame] | 28 | pushd ${cfg.logsDir} |
Matteo Scandolo | 7b64b6d | 2021-07-15 12:07:02 -0700 | [diff] [blame] | 29 | tar czf ${cfg.logsDir}/combined.tgz * |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 30 | rm *.log |
Matteo Scandolo | 544fa7b | 2021-07-23 11:03:24 -0700 | [diff] [blame] | 31 | popd |
Matteo Scandolo | 6784281 | 2021-07-13 16:52:13 -0700 | [diff] [blame] | 32 | """ |
| 33 | |
| 34 | } |
| 35 | } |