From 02888105a80213ce65c2bbadd9e04c1e3b37a6b2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 12 Mar 2018 13:52:36 +0100 Subject: [PATCH] Add a hydra.conf option to enable email notification Note that it's disabled by default. --- src/lib/Hydra/Controller/Jobset.pm | 3 +++ src/lib/Hydra/Plugin/EmailNotification.pm | 2 ++ src/root/edit-jobset.tt | 4 ++-- src/root/jobset.tt | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 3087f477..42accac0 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -47,6 +47,8 @@ sub jobset_GET { $c->stash->{totalShares} = getTotalShares($c->model('DB')->schema); + $c->stash->{emailNotification} = $c->config->{email_notification} // 0; + $self->status_ok($c, entity => $c->stash->{jobset}); } @@ -173,6 +175,7 @@ sub edit : Chained('jobsetChain') PathPart Args(0) { $c->stash->{edit} = !defined $c->stash->{params}->{cloneJobset}; $c->stash->{cloneJobset} = defined $c->stash->{params}->{cloneJobset}; $c->stash->{totalShares} = getTotalShares($c->model('DB')->schema); + $c->stash->{emailNotification} = $c->config->{email_notification} // 0; } diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index c7bc5d95..c2887631 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -44,6 +44,8 @@ EOF sub buildFinished { my ($self, $build, $dependents) = @_; + return unless $self->{config}->{email_notification} // 0; + die unless $build->finished; # Figure out to whom to send notification for each build. For diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index 30b9a4c9..6c380a3a 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -130,7 +130,7 @@
@@ -138,7 +138,7 @@
- jobset.emailoverride) %]/> + jobset.emailoverride) %] [%IF !emailNotification%]disabled=1[%END%] />
diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 2cf92a35..33139c74 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -148,6 +148,7 @@ Scheduling shares: [% jobset.schedulingshares %] [% IF totalShares %] ([% f = format("%.2f"); f(jobset.schedulingshares / totalShares * 100) %]% out of [% totalShares %] shares)[% END %] + [% IF emailNotification %] Enable email notification: [% jobset.enableemail ? "Yes" : "No" %] @@ -156,6 +157,7 @@ Email override: [% HTML.escape(jobset.emailoverride) %] + [% END %] Number of evaluations to keep: [% jobset.keepnr %]