From 3119cc7edca681b0f3331c2a56fec05e50ffe942 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 7 Jul 2009 16:15:38 +0000 Subject: [PATCH] --- deps.nix | 4 +++- doc/dev-notes.txt | 6 ++++++ src/script/hydra_build.pl | 31 +++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/deps.nix b/deps.nix index 14b5f1b5..2d3a43f3 100644 --- a/deps.nix +++ b/deps.nix @@ -15,5 +15,7 @@ with pkgs; perlPackages.IOCompressBzip2 perlPackages.Readonly perlPackages.DBDPg - perlPackages.EmailSend + perlPackages.EmailSender + perlPackages.EmailSimpleCreator + perlPackages.ModulePluggable ] diff --git a/doc/dev-notes.txt b/doc/dev-notes.txt index 8b914f00..5b1bed15 100644 --- a/doc/dev-notes.txt +++ b/doc/dev-notes.txt @@ -123,3 +123,9 @@ * Delete all scheduled builds that are not already building: delete from builds where finished = 0 and not exists (select 1 from buildschedulinginfo s where s.id = builds.id and busy = 1); + + +* Installing deps.nix in a profile for testing: + + $ nix-env -p /nix/var/nix/profiles/per-user/eelco/hydra-deps -f deps.nix -i \* --arg pkgs 'import /home/eelco/Dev/nixpkgs {}' + diff --git a/src/script/hydra_build.pl b/src/script/hydra_build.pl index f40d196f..feb375ea 100755 --- a/src/script/hydra_build.pl +++ b/src/script/hydra_build.pl @@ -5,6 +5,10 @@ use File::Basename; use File::stat; use Hydra::Schema; use Hydra::Helper::Nix; +use Email::Sender::Simple qw(sendmail); +use Email::Sender::Transport::SMTP; +use Email::Simple; +use Email::Simple::Creator; STDOUT->autoflush(); @@ -19,6 +23,28 @@ sub getBuildLog { } +sub sendEmailNotification { + my ($build) = @_; + + print $build, " ", $build->maintainers, "\n"; + + return if !$build->maintainers; + + my $email = Email::Simple->create( + header => [ + To => $build->maintainers, + From => "Hydra ", + Subject => "Build " . $build->id . " finished", + ], + body => "Build finished!\n", + ); + + print $email->as_string; + + sendmail($email); +} + + sub doBuild { my ($build) = @_; @@ -256,12 +282,17 @@ sub doBuild { $build->schedulingInfo->delete; }); + + #sendEmailNotification $build; } my $buildId = $ARGV[0] or die; print STDERR "performing build $buildId\n"; +#sendEmailNotification $db->resultset('Builds')->find($buildId); +#exit 0; + # Lock the build. If necessary, steal the lock from the parent # process (runner.pl). This is so that if the runner dies, the # children (i.e. the build.pl instances) can continue to run and won't