hydra-queue-runner: Send build notifications

Since our notification plugins are written in Perl, sending
notification from C++ requires a small Perl helper named
‘hydra-notify’.
This commit is contained in:
Eelco Dolstra
2015-06-23 00:14:49 +02:00
parent 5312e1209b
commit a317d24b29
4 changed files with 111 additions and 6 deletions

View File

@ -9,6 +9,7 @@ distributable_scripts = \
hydra-update-gc-roots \
hydra-s3-backup-collect-garbage \
hydra-create-user \
hydra-notify \
nix-prefetch-git \
nix-prefetch-bzr \
nix-prefetch-hg

View File

@ -1,4 +1,4 @@
#! /var/run/current-system/sw/bin/perl
#! /run/current-system/sw/bin/perl
use strict;
use utf8;

35
src/script/hydra-notify Executable file
View File

@ -0,0 +1,35 @@
#! /run/current-system/sw/bin/perl
use strict;
use utf8;
use Hydra::Plugin;
use Hydra::Helper::Nix;
use Hydra::Helper::PluginHooks;
STDERR->autoflush(1);
binmode STDERR, ":encoding(utf8)";
my $config = getHydraConfig();
my $db = Hydra::Model::DB->new();
my @plugins = Hydra::Plugin->instantiate(db => $db, config => $config);
my $cmd = shift @ARGV or die "Syntax: hydra-notify build BUILD-ID [BUILD-IDs...]\n";
if ($cmd eq "build") {
my $buildId = shift @ARGV or die;
my $build = $db->resultset('Builds')->find($buildId)
or die "build $buildId does not exist\n";
my @dependents;
foreach my $id (@ARGV) {
my $dep = $db->resultset('Builds')->find($id)
or die "build $id does not exist\n";
push @dependents, $dep;
}
notifyBuildFinished(\@plugins, $build, [@dependents]);
}
else {
die "unknown action $cmd";
}