hydra-notify: move BuildStarted processing to an Event
This commit is contained in:
committed by
Your Name
parent
10e85e3422
commit
4fdb20d3bd
@ -19,7 +19,29 @@ sub parse :prototype(@) {
|
||||
|
||||
sub new {
|
||||
my ($self, $id) = @_;
|
||||
return bless { "build_id" => $id }, $self;
|
||||
return bless {
|
||||
"build_id" => $id,
|
||||
"build" => undef
|
||||
}, $self;
|
||||
}
|
||||
|
||||
sub load {
|
||||
my ($self, $db) = @_;
|
||||
|
||||
if (!defined($self->{"build"})) {
|
||||
$self->{"build"} = $db->resultset('Builds')->find($self->{"build_id"})
|
||||
or die "build $self->{'build_id'} does not exist\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, $db, $plugin) = @_;
|
||||
|
||||
$self->load($db);
|
||||
|
||||
$plugin->buildStarted($self->{"build"});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -44,22 +44,6 @@ sub runPluginsForEvent {
|
||||
}
|
||||
}
|
||||
|
||||
sub buildStarted {
|
||||
my ($buildId) = @_;
|
||||
|
||||
my $build = $db->resultset('Builds')->find($buildId)
|
||||
or die "build $buildId does not exist\n";
|
||||
|
||||
foreach my $plugin (@plugins) {
|
||||
eval {
|
||||
$plugin->buildStarted($build);
|
||||
1;
|
||||
} or do {
|
||||
print STDERR "error with $plugin->buildStarted: $@\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub buildFinished {
|
||||
my ($buildId, @deps) = @_;
|
||||
|
||||
@ -136,7 +120,8 @@ while (!$queued_only) {
|
||||
|
||||
eval {
|
||||
if ($channelName eq "build_started") {
|
||||
buildStarted(int($payload[0]));
|
||||
my $event = Hydra::Event::new_event($channelName, $message->{"payload"});
|
||||
runPluginsForEvent($event);
|
||||
} elsif ($channelName eq "build_finished") {
|
||||
my $buildId = int($payload[0]);
|
||||
buildFinished($buildId, @payload[1..$#payload]);
|
||||
|
Reference in New Issue
Block a user