From 7913701d540307e1f14742da7d8c2e169eb03608 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 09:44:51 -0400 Subject: [PATCH 01/11] Factor a getResponsibleAuthors helper out of the HipChatNotification Signed-off-by: Shea Levy --- src/lib/Hydra/Helper/CatalystUtils.pm | 37 +++++++++++++++++++++ src/lib/Hydra/Plugin/HipChatNotification.pm | 30 ++--------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 9f257418..b8a35aaf 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -27,6 +27,7 @@ our @EXPORT = qw( parseJobsetName showJobName showStatus + getResponsibleAuthors ); @@ -250,4 +251,40 @@ sub showStatus { } +# Determine who broke/fixed the build. +sub getResponsibleAuthors { + my ($build, $plugins) = @_; + + my $prevBuild = getPreviousBuild($build); + + my $nrCommits = 0; + my %authors; + + if ($prevBuild) { + foreach my $curInput ($build->buildinputs_builds) { + next unless ($curInput->type eq "git" || $curInput->type eq "hg"); + my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name }); + next unless defined $prevInput; + + next if $curInput->type ne $prevInput->type; + next if $curInput->uri ne $prevInput->uri; + next if $curInput->revision eq $prevInput->revision; + + my @commits; + foreach my $plugin (@{$plugins}) { + push @commits, @{$plugin->getCommits($curInput->type, $curInput->uri, $prevInput->revision, $curInput->revision)}; + } + + foreach my $commit (@commits) { + #print STDERR "$commit->{revision} by $commit->{author}\n"; + $authors{$commit->{author}} = $commit->{email}; + $nrCommits++; + } + } + } + + return (\%authors, $nrCommits); +} + + 1; diff --git a/src/lib/Hydra/Plugin/HipChatNotification.pm b/src/lib/Hydra/Plugin/HipChatNotification.pm index fb8f538b..59350ed3 100644 --- a/src/lib/Hydra/Plugin/HipChatNotification.pm +++ b/src/lib/Hydra/Plugin/HipChatNotification.pm @@ -40,31 +40,7 @@ sub buildFinished { # Determine who broke/fixed the build. my $prevBuild = getPreviousBuild($build); - my $nrCommits = 0; - my %authors; - - if ($prevBuild) { - foreach my $curInput ($build->buildinputs_builds) { - next unless ($curInput->type eq "git" || $curInput->type eq "hg"); - my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name }); - next unless defined $prevInput; - - next if $curInput->type ne $prevInput->type; - next if $curInput->uri ne $prevInput->uri; - next if $curInput->revision eq $prevInput->revision; - - my @commits; - foreach my $plugin (@{$self->{plugins}}) { - push @commits, @{$plugin->getCommits($curInput->type, $curInput->uri, $prevInput->revision, $curInput->revision)}; - } - - foreach my $commit (@commits) { - #print STDERR "$commit->{revision} by $commit->{author}\n"; - $authors{$commit->{author}} = $commit->{email}; - $nrCommits++; - } - } - } + my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); # Send a message to each room. foreach my $roomId (keys %rooms) { @@ -84,9 +60,9 @@ sub buildFinished { $msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0; $msg .= ": " . showStatus($build) . ""; - if (scalar keys %authors > 0) { + if (scalar keys %{$authors} > 0) { # FIXME: HTML escaping - my @x = map { "$_" } (sort keys %authors); + my @x = map { "$_" } (sort keys %{$authors}); $msg .= ", likely due to "; $msg .= "$nrCommits commits by " if $nrCommits > 1; $msg .= join(" or ", scalar @x > 1 ? join(", ", @x[0..scalar @x - 2]) : (), $x[-1]); From 6342464110aa8c6dc2c958dbe8a94ad2801676a6 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:01:40 -0400 Subject: [PATCH 02/11] Add DB columns for when to notify responsible committers and which inputs should be checked Signed-off-by: Shea Levy --- src/sql/hydra.sql | 3 +++ src/sql/upgrade-23.sql | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 src/sql/upgrade-23.sql diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 23fc7925..2df03620 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -57,6 +57,7 @@ create table Jobsets ( triggerTime integer, -- set if we were triggered by a push event enabled integer not null default 1, enableEmail integer not null default 1, + emailResponsible integer not null default 0, -- whether to email committers responsible for a build change hidden integer not null default 0, emailOverride text not null, keepnr integer not null default 3, @@ -77,6 +78,7 @@ create table JobsetInputs ( jobset text not null, name text not null, type text not null, -- "svn", "path", "uri", "string", "boolean", "nix" + checkResponsible integer not null default 0, -- whether this input should be checked for responsbile commits primary key (project, jobset, name), foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade ); @@ -257,6 +259,7 @@ create table BuildInputs ( uri text, revision text, value text, + checkResponsible integer not null default 0, dependency integer, -- build ID of the input, for type == 'build' path text, diff --git a/src/sql/upgrade-23.sql b/src/sql/upgrade-23.sql new file mode 100644 index 00000000..2a53fe85 --- /dev/null +++ b/src/sql/upgrade-23.sql @@ -0,0 +1,3 @@ +alter table Jobsets add column emailResponsible integer not null default 0; +alter table JobsetInputs add column checkResponsible integer not null default 0; +alter table BuildInputs add column checkResponsible integer not null default 0; From 07157f8125c63c3946b8952fd46f1a3063979b5a Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:06:09 -0400 Subject: [PATCH 03/11] Update Schema classes Signed-off-by: Shea Levy --- src/lib/Hydra/Schema/BuildInputs.pm | 12 ++++++++++-- src/lib/Hydra/Schema/JobsetInputs.pm | 12 ++++++++++-- src/lib/Hydra/Schema/Jobsets.pm | 12 ++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/lib/Hydra/Schema/BuildInputs.pm b/src/lib/Hydra/Schema/BuildInputs.pm index d450fbe1..3c2bb0fb 100644 --- a/src/lib/Hydra/Schema/BuildInputs.pm +++ b/src/lib/Hydra/Schema/BuildInputs.pm @@ -72,6 +72,12 @@ __PACKAGE__->table("BuildInputs"); data_type: 'text' is_nullable: 1 +=head2 checkresponsible + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + =head2 dependency data_type: 'integer' @@ -105,6 +111,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "value", { data_type => "text", is_nullable => 1 }, + "checkresponsible", + { data_type => "integer", default_value => 0, is_nullable => 0 }, "dependency", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "path", @@ -168,7 +176,7 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-06-13 01:54:50 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tKZAybbNaRIMs9n5tHkqPw +# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ks8PxHXTwtG+Zco0CAzECg 1; diff --git a/src/lib/Hydra/Schema/JobsetInputs.pm b/src/lib/Hydra/Schema/JobsetInputs.pm index 48464bbf..f1773693 100644 --- a/src/lib/Hydra/Schema/JobsetInputs.pm +++ b/src/lib/Hydra/Schema/JobsetInputs.pm @@ -57,6 +57,12 @@ __PACKAGE__->table("JobsetInputs"); data_type: 'text' is_nullable: 0 +=head2 checkresponsible + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + =cut __PACKAGE__->add_columns( @@ -68,6 +74,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0 }, "type", { data_type => "text", is_nullable => 0 }, + "checkresponsible", + { data_type => "integer", default_value => 0, is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -142,7 +150,7 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-06-13 01:54:50 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UXBzqO0vHPql4LYyXpgEQg +# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OvSrNdXWqco666sy+rvsKw 1; diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index f31a75f7..2953b063 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -95,6 +95,12 @@ __PACKAGE__->table("Jobsets"); default_value: 1 is_nullable: 0 +=head2 emailresponsible + + data_type: 'integer' + default_value: 0 + is_nullable: 0 + =head2 hidden data_type: 'integer' @@ -154,6 +160,8 @@ __PACKAGE__->add_columns( { data_type => "integer", default_value => 1, is_nullable => 0 }, "enableemail", { data_type => "integer", default_value => 1, is_nullable => 0 }, + "emailresponsible", + { data_type => "integer", default_value => 0, is_nullable => 0 }, "hidden", { data_type => "integer", default_value => 0, is_nullable => 0 }, "emailoverride", @@ -287,7 +295,7 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-09-25 14:10:28 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cAZ4+c7OhqGW8ATru8Foiw +# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hJ41oHEb9PjzluvL7f/ypw 1; From 3e4a4e3761797454f6bff199f06135aec21aafc1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:17:22 -0400 Subject: [PATCH 04/11] Propagate checkresponsible from JobsetInput to BuildInput Signed-off-by: Shea Levy --- src/lib/Hydra/Helper/AddBuilds.pm | 8 ++++++-- src/script/hydra-evaluator | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index e0196a81..d8b1af8b 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -148,7 +148,7 @@ sub fetchInputSystemBuild { } sub fetchInput { - my ($plugins, $db, $project, $jobset, $name, $type, $value) = @_; + my ($plugins, $db, $project, $jobset, $name, $type, $value, $checkresponsbile) = @_; my @inputs; if ($type eq "build") { @@ -177,7 +177,10 @@ sub fetchInput { die "input `$name' has unknown type `$type'." unless $found; } - $_->{type} = $type foreach @inputs; + foreach my $input (@inputs) { + $input->{type} = $type; + $input->{checkresponsible} = $checkresponsible; + } return @inputs; } @@ -542,6 +545,7 @@ sub checkBuild { , uri => $input->{uri} , revision => $input->{revision} , value => $input->{value} + , checkresponsible => $input->{checkresponsible} , dependency => $input->{id} , path => $input->{storePath} || "" # !!! temporary hack , sha256hash => $input->{sha256hash} diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 0fe15ccf..1fb0461c 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -34,7 +34,7 @@ sub fetchInputs { foreach my $input ($jobset->jobsetinputs->all) { foreach my $alt ($input->jobsetinputalts->all) { push @{$$inputInfo{$input->name}}, $_ - foreach fetchInput($plugins, $db, $project, $jobset, $input->name, $input->type, $alt->value); + foreach fetchInput($plugins, $db, $project, $jobset, $input->name, $input->type, $alt->value, $input->checkresponsible); } } } From 3e1f9309287a3479e9f3a5fc9748054f3125d221 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:25:46 -0400 Subject: [PATCH 05/11] Enable setting emailresponsible in the edit jobset form Signed-off-by: Shea Levy --- src/lib/Hydra/Controller/Jobset.pm | 1 + src/root/edit-jobset.tt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index b8a149d2..6a2090b2 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -206,6 +206,7 @@ sub updateJobset { , nixexprinput => $nixExprInput , enabled => $enabled ? 1 : 0 , enableemail => defined $c->stash->{params}->{enableemail} ? 1 : 0 + , emailresponsible => defined $c->stash->{params}->{emailresponsible} ? 1 : 0 , emailoverride => trim($c->stash->{params}->{emailoverride}) || "" , hidden => defined $c->stash->{params}->{visible} ? 0 : 1 , keepnr => int(trim($c->stash->{params}->{keepnr})) diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index c299f60f..bf7e94d3 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -115,6 +115,14 @@ +
+
+ +
+
+
From 58ad3b4b6ce565a269dc77cb0ac703942d70b00d Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:46:10 -0400 Subject: [PATCH 06/11] Enable setting checkresponsible in the edit jobset form Signed-off-by: Shea Levy --- src/lib/Hydra/Controller/Jobset.pm | 6 +++++- src/root/edit-jobset.tt | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 6a2090b2..0fa18717 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -229,7 +229,11 @@ sub updateJobset { error($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/; error($c, "Invalid input type ‘$type’.") unless defined $c->stash->{inputTypes}->{$type}; - my $input = $jobset->jobsetinputs->create({ name => $name, type => $type }); + my $input = $jobset->jobsetinputs->create({ + name => $name, + type => $type, + checkresponsible => $c->stash->{params}->{"input-$baseName-checkresponsible"} + }); # Set the values for this input. my @values = ref($values) eq 'ARRAY' ? @{$values} : ($values); diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index bf7e94d3..47213f11 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -25,20 +25,23 @@ [% END %] [% IF edit %][% END %] + + + [% END %] [% BLOCK renderJobsetInputs %] - + [% FOREACH input IN jobset.jobsetinputs %] [% INCLUDE renderJobsetInput input=input baseName="input-$input.name" %] [% END %] - +
Input nameTypeValues
Input nameTypeValuesCheck for responsible commits?
@@ -164,6 +167,7 @@ var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show(); $("#input-template-name", x).attr("name", newid + "-name"); $("#input-template-type", x).attr("name", newid + "-type"); + $("#input-template-checkresponsible", x).attr("name", newid + "-checkresponsible"); $("#input-template", x).attr("id", newid); return false; }); From 2c90857689428cc870a7899117aab453c4a51568 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:47:22 -0400 Subject: [PATCH 07/11] getResponsibleAuthors: Respect checkResponsible Signed-off-by: Shea Levy --- src/lib/Hydra/Helper/CatalystUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index b8a35aaf..08ca5587 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -262,7 +262,7 @@ sub getResponsibleAuthors { if ($prevBuild) { foreach my $curInput ($build->buildinputs_builds) { - next unless ($curInput->type eq "git" || $curInput->type eq "hg"); + next unless (($curInput->type eq "git" || $curInput->type eq "hg") && $curInput->checkresponsible); my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name }); next unless defined $prevInput; From 272d9e235da03ad1c7744459338378d401165d30 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 10:48:51 -0400 Subject: [PATCH 08/11] Remove unused assignment Signed-off-by: Shea Levy --- src/lib/Hydra/Plugin/HipChatNotification.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/Hydra/Plugin/HipChatNotification.pm b/src/lib/Hydra/Plugin/HipChatNotification.pm index 59350ed3..702d6bfb 100644 --- a/src/lib/Hydra/Plugin/HipChatNotification.pm +++ b/src/lib/Hydra/Plugin/HipChatNotification.pm @@ -37,9 +37,6 @@ sub buildFinished { return if scalar keys %rooms == 0; - # Determine who broke/fixed the build. - my $prevBuild = getPreviousBuild($build); - my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); # Send a message to each room. From f8b80c99c21938d224c7f14082ac5c902b165d38 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 11:13:37 -0400 Subject: [PATCH 09/11] Include who-broke-the-build information in notification emails Signed-off-by: Shea Levy --- src/lib/Hydra/Plugin/EmailNotification.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index 1e484483..87e1fb4b 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -29,6 +29,11 @@ The following dependent jobs also failed: [% END -%] [% END -%] + +[% IF nrCommits > 0 -%] +This is likely due to [% IF nrCommits > 1 -%][% nrCommits %] commits by [% END -%][% authorList %]. +[% END -%] + [% IF build.buildstatus == 0 -%] Yay! [% ELSE -%] @@ -74,6 +79,13 @@ sub buildFinished { } } + my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); + my $authorList; + if (scalar keys %{authors} > 0) { + my @x = map { "$_ <$authors->{$_}>" } (sort keys %{$authors}); + $authorList = join(" or ", scalar @x > 1 ? join(", ", @[0..scalar @x - 2]): (), $x[-1]); + } + # Send an email to each interested address. # !!! should use the Template Toolkit here. @@ -89,6 +101,8 @@ sub buildFinished { , baseurl => $self->{config}->{'base_uri'} || "http://localhost:3000" , showJobName => \&showJobName, showStatus => \&showStatus , showSystem => index($build->job->name, $build->system) == -1 + , nrCommits => $nrCommits + , authorList => $authorList }; my $body; From 804617f0752d5aadd5aa1c88ecc866d3928b98c9 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 7 Oct 2013 11:21:16 -0400 Subject: [PATCH 10/11] Email responsible authors if requested Signed-off-by: Shea Levy --- src/lib/Hydra/Plugin/EmailNotification.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index 87e1fb4b..f18a6569 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -84,6 +84,9 @@ sub buildFinished { if (scalar keys %{authors} > 0) { my @x = map { "$_ <$authors->{$_}>" } (sort keys %{$authors}); $authorList = join(" or ", scalar @x > 1 ? join(", ", @[0..scalar @x - 2]): (), $x[-1]); + if ($build->jobset->emailresponsible) { + $addresses{$authors->{$_}} = { builds => [ $build ] } foreach (keys %{$authors}); + } } # Send an email to each interested address. From 26470f1656e0fda30761a0ce96a46753c740f391 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 8 Oct 2013 14:47:24 -0400 Subject: [PATCH 11/11] Check all inputs for blame but only email selected inputs Signed-off-by: Shea Levy --- src/lib/Hydra/Controller/Jobset.pm | 3 +-- src/lib/Hydra/Helper/AddBuilds.pm | 6 +++--- src/lib/Hydra/Helper/CatalystUtils.pm | 6 ++++-- src/lib/Hydra/Plugin/EmailNotification.pm | 6 ++---- src/lib/Hydra/Schema/BuildInputs.pm | 8 ++++---- src/lib/Hydra/Schema/JobsetInputs.pm | 8 ++++---- src/lib/Hydra/Schema/Jobsets.pm | 12 ++---------- src/root/edit-jobset.tt | 14 +++----------- src/script/hydra-evaluator | 2 +- src/sql/hydra.sql | 5 ++--- src/sql/upgrade-23.sql | 5 ++--- 11 files changed, 28 insertions(+), 47 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 0fa18717..75f1738a 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -206,7 +206,6 @@ sub updateJobset { , nixexprinput => $nixExprInput , enabled => $enabled ? 1 : 0 , enableemail => defined $c->stash->{params}->{enableemail} ? 1 : 0 - , emailresponsible => defined $c->stash->{params}->{emailresponsible} ? 1 : 0 , emailoverride => trim($c->stash->{params}->{emailoverride}) || "" , hidden => defined $c->stash->{params}->{visible} ? 0 : 1 , keepnr => int(trim($c->stash->{params}->{keepnr})) @@ -232,7 +231,7 @@ sub updateJobset { my $input = $jobset->jobsetinputs->create({ name => $name, type => $type, - checkresponsible => $c->stash->{params}->{"input-$baseName-checkresponsible"} + emailresponsible => defined $c->stash->{params}->{"input-$baseName-emailresponsible"} ? 1 : 0 }); # Set the values for this input. diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index d8b1af8b..99f1b85e 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -148,7 +148,7 @@ sub fetchInputSystemBuild { } sub fetchInput { - my ($plugins, $db, $project, $jobset, $name, $type, $value, $checkresponsbile) = @_; + my ($plugins, $db, $project, $jobset, $name, $type, $value, $emailresponsible) = @_; my @inputs; if ($type eq "build") { @@ -179,7 +179,7 @@ sub fetchInput { foreach my $input (@inputs) { $input->{type} = $type; - $input->{checkresponsible} = $checkresponsible; + $input->{emailresponsible} = $emailresponsible; } return @inputs; @@ -545,7 +545,7 @@ sub checkBuild { , uri => $input->{uri} , revision => $input->{revision} , value => $input->{value} - , checkresponsible => $input->{checkresponsible} + , emailresponsible => $input->{emailresponsible} , dependency => $input->{id} , path => $input->{storePath} || "" # !!! temporary hack , sha256hash => $input->{sha256hash} diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 08ca5587..296f3118 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -259,10 +259,11 @@ sub getResponsibleAuthors { my $nrCommits = 0; my %authors; + my @emailable_authors; if ($prevBuild) { foreach my $curInput ($build->buildinputs_builds) { - next unless (($curInput->type eq "git" || $curInput->type eq "hg") && $curInput->checkresponsible); + next unless ($curInput->type eq "git" || $curInput->type eq "hg"); my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name }); next unless defined $prevInput; @@ -278,12 +279,13 @@ sub getResponsibleAuthors { foreach my $commit (@commits) { #print STDERR "$commit->{revision} by $commit->{author}\n"; $authors{$commit->{author}} = $commit->{email}; + push @emailable_authors, $commit->{email} if $curInput->emailresponsible; $nrCommits++; } } } - return (\%authors, $nrCommits); + return (\%authors, $nrCommits, \@emailable_authors); } diff --git a/src/lib/Hydra/Plugin/EmailNotification.pm b/src/lib/Hydra/Plugin/EmailNotification.pm index f18a6569..e30f48af 100644 --- a/src/lib/Hydra/Plugin/EmailNotification.pm +++ b/src/lib/Hydra/Plugin/EmailNotification.pm @@ -79,14 +79,12 @@ sub buildFinished { } } - my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins}); + my ($authors, $nrCommits, $emailable_authors) = getResponsibleAuthors($build, $self->{plugins}); my $authorList; if (scalar keys %{authors} > 0) { my @x = map { "$_ <$authors->{$_}>" } (sort keys %{$authors}); $authorList = join(" or ", scalar @x > 1 ? join(", ", @[0..scalar @x - 2]): (), $x[-1]); - if ($build->jobset->emailresponsible) { - $addresses{$authors->{$_}} = { builds => [ $build ] } foreach (keys %{$authors}); - } + $addresses{$_} = { builds => [ $build ] } foreach (@{$emailable_authors}); } # Send an email to each interested address. diff --git a/src/lib/Hydra/Schema/BuildInputs.pm b/src/lib/Hydra/Schema/BuildInputs.pm index 3c2bb0fb..dafae860 100644 --- a/src/lib/Hydra/Schema/BuildInputs.pm +++ b/src/lib/Hydra/Schema/BuildInputs.pm @@ -72,7 +72,7 @@ __PACKAGE__->table("BuildInputs"); data_type: 'text' is_nullable: 1 -=head2 checkresponsible +=head2 emailresponsible data_type: 'integer' default_value: 0 @@ -111,7 +111,7 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "value", { data_type => "text", is_nullable => 1 }, - "checkresponsible", + "emailresponsible", { data_type => "integer", default_value => 0, is_nullable => 0 }, "dependency", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, @@ -176,7 +176,7 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ks8PxHXTwtG+Zco0CAzECg +# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-08 13:08:15 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OaJPzRM+8XGsu3eIkqeYEw 1; diff --git a/src/lib/Hydra/Schema/JobsetInputs.pm b/src/lib/Hydra/Schema/JobsetInputs.pm index f1773693..c6dafde1 100644 --- a/src/lib/Hydra/Schema/JobsetInputs.pm +++ b/src/lib/Hydra/Schema/JobsetInputs.pm @@ -57,7 +57,7 @@ __PACKAGE__->table("JobsetInputs"); data_type: 'text' is_nullable: 0 -=head2 checkresponsible +=head2 emailresponsible data_type: 'integer' default_value: 0 @@ -74,7 +74,7 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 0 }, "type", { data_type => "text", is_nullable => 0 }, - "checkresponsible", + "emailresponsible", { data_type => "integer", default_value => 0, is_nullable => 0 }, ); @@ -150,7 +150,7 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OvSrNdXWqco666sy+rvsKw +# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-08 13:06:15 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+mZZqLjQNwblb/EWW1alLQ 1; diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 2953b063..8ca9d174 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -95,12 +95,6 @@ __PACKAGE__->table("Jobsets"); default_value: 1 is_nullable: 0 -=head2 emailresponsible - - data_type: 'integer' - default_value: 0 - is_nullable: 0 - =head2 hidden data_type: 'integer' @@ -160,8 +154,6 @@ __PACKAGE__->add_columns( { data_type => "integer", default_value => 1, is_nullable => 0 }, "enableemail", { data_type => "integer", default_value => 1, is_nullable => 0 }, - "emailresponsible", - { data_type => "integer", default_value => 0, is_nullable => 0 }, "hidden", { data_type => "integer", default_value => 0, is_nullable => 0 }, "emailoverride", @@ -295,7 +287,7 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-07 14:04:49 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hJ41oHEb9PjzluvL7f/ypw +# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-10-08 13:06:15 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BjT60mlrN7bnljqCMHbPEw 1; diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index 47213f11..383bbea9 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -26,7 +26,7 @@ [% IF edit %][% END %] - + [% END %] @@ -34,7 +34,7 @@ [% BLOCK renderJobsetInputs %] - + [% FOREACH input IN jobset.jobsetinputs %] @@ -118,14 +118,6 @@ -
-
- -
-
-
@@ -167,7 +159,7 @@ var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show(); $("#input-template-name", x).attr("name", newid + "-name"); $("#input-template-type", x).attr("name", newid + "-type"); - $("#input-template-checkresponsible", x).attr("name", newid + "-checkresponsible"); + $("#input-template-emailresponsible", x).attr("name", newid + "-emailresponsible"); $("#input-template", x).attr("id", newid); return false; }); diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 1fb0461c..baf7162e 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -34,7 +34,7 @@ sub fetchInputs { foreach my $input ($jobset->jobsetinputs->all) { foreach my $alt ($input->jobsetinputalts->all) { push @{$$inputInfo{$input->name}}, $_ - foreach fetchInput($plugins, $db, $project, $jobset, $input->name, $input->type, $alt->value, $input->checkresponsible); + foreach fetchInput($plugins, $db, $project, $jobset, $input->name, $input->type, $alt->value, $input->emailresponsible); } } } diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 2df03620..8717614a 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -57,7 +57,6 @@ create table Jobsets ( triggerTime integer, -- set if we were triggered by a push event enabled integer not null default 1, enableEmail integer not null default 1, - emailResponsible integer not null default 0, -- whether to email committers responsible for a build change hidden integer not null default 0, emailOverride text not null, keepnr integer not null default 3, @@ -78,7 +77,7 @@ create table JobsetInputs ( jobset text not null, name text not null, type text not null, -- "svn", "path", "uri", "string", "boolean", "nix" - checkResponsible integer not null default 0, -- whether this input should be checked for responsbile commits + emailResponsible integer not null default 0, -- whether to email committers to this input who change a build primary key (project, jobset, name), foreign key (project, jobset) references Jobsets(project, name) on delete cascade on update cascade ); @@ -259,7 +258,7 @@ create table BuildInputs ( uri text, revision text, value text, - checkResponsible integer not null default 0, + emailResponsible integer not null default 0, dependency integer, -- build ID of the input, for type == 'build' path text, diff --git a/src/sql/upgrade-23.sql b/src/sql/upgrade-23.sql index 2a53fe85..585711e6 100644 --- a/src/sql/upgrade-23.sql +++ b/src/sql/upgrade-23.sql @@ -1,3 +1,2 @@ -alter table Jobsets add column emailResponsible integer not null default 0; -alter table JobsetInputs add column checkResponsible integer not null default 0; -alter table BuildInputs add column checkResponsible integer not null default 0; +alter table JobsetInputs add column emailResponsible integer not null default 0; +alter table BuildInputs add column emailResponsible integer not null default 0;
Input nameTypeValuesCheck for responsible commits?
Input nameTypeValuesNotify committers