2017-03-13 17:18:22 +01:00
|
|
|
package Hydra::Plugin::CompressLog;
|
|
|
|
|
|
|
|
use strict;
|
2021-08-19 16:36:43 -04:00
|
|
|
use warnings;
|
2017-03-13 17:18:22 +01:00
|
|
|
use utf8;
|
|
|
|
use parent 'Hydra::Plugin';
|
|
|
|
use Hydra::Helper::CatalystUtils;
|
|
|
|
|
|
|
|
sub stepFinished {
|
|
|
|
my ($self, $step, $logPath) = @_;
|
|
|
|
|
2022-06-12 17:57:49 +02:00
|
|
|
my $doCompress = $self->{config}->{'compress_build_logs'} // '1';
|
|
|
|
my $silent = $self->{config}->{'compress_build_logs_silent'} // '0';
|
|
|
|
my $compression = $self->{config}->{'compress_build_logs_compression'} // 'bzip2';
|
2017-03-13 17:18:22 +01:00
|
|
|
|
2022-06-12 17:57:49 +02:00
|
|
|
if (not -e $logPath or $doCompress ne "1") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($silent ne '1') {
|
|
|
|
print STDERR "compressing '$logPath' with $compression...\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($compression eq 'bzip2') {
|
|
|
|
system('bzip2', '--force', $logPath);
|
|
|
|
} elsif ($compression eq 'zstd') {
|
|
|
|
system('zstd', '--rm', '--quiet', '-T0', $logPath);
|
|
|
|
} else {
|
|
|
|
print STDERR "unknown compression type '$compression'\n";
|
2017-03-13 17:18:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|