Check if we want to send email for a build before iterating through its users

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-07-05 14:06:10 -04:00
parent 117ae78a45
commit 93a14ccf32

View file

@ -52,23 +52,23 @@ sub buildFinished {
my %addresses; my %addresses;
foreach my $b ($build, @{$dependents}) { foreach my $b ($build, @{$dependents}) {
my $prevBuild = getPreviousBuild($b); my $prevBuild = getPreviousBuild($b);
# Do we want to send mail for this build?
unless ($ENV{'HYDRA_FORCE_SEND_MAIL'}) {
next unless $b->jobset->enableemail;
# If build is cancelled or aborted, do not send email.
next if $b->buildstatus == 4 || $b->buildstatus == 3;
# If there is a previous (that is not cancelled or aborted) build
# with same buildstatus, do not send email.
next if defined $prevBuild && ($b->buildstatus == $prevBuild->buildstatus);
}
my $to = $b->jobset->emailoverride ne "" ? $b->jobset->emailoverride : $b->maintainers; my $to = $b->jobset->emailoverride ne "" ? $b->jobset->emailoverride : $b->maintainers;
foreach my $address (split ",", $to) { foreach my $address (split ",", $to) {
$address = trim $address; $address = trim $address;
# Do we want to send mail for this build?
unless ($ENV{'HYDRA_FORCE_SEND_MAIL'}) {
next unless $b->jobset->enableemail;
# If build is cancelled or aborted, do not send email.
next if $b->buildstatus == 4 || $b->buildstatus == 3;
# If there is a previous (that is not cancelled or aborted) build
# with same buildstatus, do not send email.
next if defined $prevBuild && ($b->buildstatus == $prevBuild->buildstatus);
}
$addresses{$address} //= { builds => [] }; $addresses{$address} //= { builds => [] };
push @{$addresses{$address}->{builds}}, $b; push @{$addresses{$address}->{builds}}, $b;
} }