0
0
Fork 0
forked from lix-project/hydra

Add duration to Slack notification.

This commit is contained in:
Rob Vermaas 2018-11-20 14:57:50 +01:00
parent cd234f6a14
commit 14d5577bf8

View file

@ -7,6 +7,23 @@ use LWP::UserAgent;
use Hydra::Helper::CatalystUtils;
use JSON;
sub renderDuration {
my ($build) = @_;
my $duration = $build->stoptime - $build->starttime;
my $res = "";
if ($duration >= 24*60*60) {
$res .= ($duration / (24*60*60)) . "d";
}
if ($duration >= 60*60) {
$res .= (($duration / (60*60)) % 24) . "h";
}
if ($duration >= 60) {
$res .= (($duration / 60) % 60) . "m";
}
$res .= ($duration % 60) . "s";
return $res;
}
sub buildFinished {
my ($self, $build, $dependents) = @_;
my $cfg = $self->{config}->{slack};
@ -61,7 +78,7 @@ sub buildFinished {
my $text = "";
$text .= "Job <$baseurl/job/${\$build->project->name}/${\$build->jobset->name}/${\$build->job->name}|${\showJobName($build)}>";
$text .= " (and ${\scalar @deps} others)" if scalar @deps > 0;
$text .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">";
$text .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">". " in " . renderDuration($build);
if (scalar keys %{$authors} > 0) {
# FIXME: escaping