* email notification of evaluation errors to project owner (if desired)

This commit is contained in:
Rob Vermaas 2009-12-18 12:07:45 +00:00
parent d6416ada4e
commit 044edfb764
3 changed files with 48 additions and 4 deletions

View file

@ -39,6 +39,8 @@ __PACKAGE__->add_columns(
is_nullable => 0, is_nullable => 0,
size => undef, size => undef,
}, },
"emailonerror",
{ data_type => "integer", default_value => 0, is_nullable => 0, size => undef },
); );
__PACKAGE__->set_primary_key("username"); __PACKAGE__->set_primary_key("username");
__PACKAGE__->has_many( __PACKAGE__->has_many(
@ -53,8 +55,8 @@ __PACKAGE__->has_many(
); );
# Created by DBIx::Class::Schema::Loader v0.04999_09 @ 2009-11-17 16:04:13 # Created by DBIx::Class::Schema::Loader v0.04999_09 @ 2009-12-18 12:57:04
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oBiKpCxHGZcGujhY/ZbbxA # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/AWZnceSVTAlb5Tru9T1+g
# You can replace this text with custom content, and it will be preserved on regeneration # You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -7,11 +7,18 @@ use Hydra::Helper::Nix;
use Hydra::Helper::AddBuilds; use Hydra::Helper::AddBuilds;
use Digest::SHA qw(sha256_hex); use Digest::SHA qw(sha256_hex);
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP;
use Email::Simple;
use Email::Simple::Creator;
use Sys::Hostname::Long;
use Config::General;
STDOUT->autoflush(); STDOUT->autoflush();
my $db = openHydraDB; my $db = openHydraDB;
my %config = new Config::General($ENV{"HYDRA_CONFIG"})->getall;
sub fetchInputs { sub fetchInputs {
my ($project, $jobset, $inputInfo) = @_; my ($project, $jobset, $inputInfo) = @_;
@ -31,8 +38,42 @@ sub setJobsetError {
$jobset->update({errormsg => $errorMsg, errortime => time}); $jobset->update({errormsg => $errorMsg, errortime => time});
}); });
}; };
sendJobsetErrorNotification($jobset, $errorMsg);
} }
sub sendJobsetErrorNotification() {
my ($jobset, $errorMsg) = @_;
return if $jobset->project->owner->emailonerror == 0;
my $projectName = $jobset->project->name;
my $jobsetName = $jobset->name;
my $sender = $config{'notification_sender'} ||
(($ENV{'USER'} || "hydra") . "@" . hostname_long);
my $body = "Hi,\n"
. "\n"
. "This is to let you know that Hydra jobset evalation of $projectName:$jobsetName "
. "resulted in the following error:\n"
. "\n"
. "$errorMsg"
. "\n"
. "Regards,\n\nThe Hydra build daemon.\n";
my $email = Email::Simple->create(
header => [
To => $jobset->project->owner->emailaddress,
From => "Hydra Build Daemon <$sender>",
Subject => "Hydra $projectName:$jobsetName evaluation error",
],
body => $body,
);
print $email->as_string if $ENV{'HYDRA_MAIL_TEST'};
sendmail($email);
}
sub permute { sub permute {
my @list = @_; my @list = @_;

View file

@ -2,7 +2,8 @@ create table Users (
userName text primary key not null, userName text primary key not null,
fullName text, fullName text,
emailAddress text not null, emailAddress text not null,
password text not null -- sha256 hash password text not null, -- sha256 hash
emailOnError integer not null default 0
); );