From 93a14ccf326545ad7429e6a6317d6ee3f2a1b991 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Fri, 5 Jul 2013 14:06:10 -0400 Subject: [PATCH] Check if we want to send email for a build before iterating through its users Signed-off-by: Shea Levy --- src/lib/Hydra/Plugin/EmailNotification.pm | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index 5a043b8e..b373175f 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -52,23 +52,23 @@ sub buildFinished { my %addresses; foreach my $b ($build, @{$dependents}) { 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; foreach my $address (split ",", $to) { $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 => [] }; push @{$addresses{$address}->{builds}}, $b; }