hydra-notify: move StepFinished processing to an Event
This commit is contained in:
committed by
Your Name
parent
4fdb20d3bd
commit
4a1389e36e
@ -23,7 +23,37 @@ sub parse :prototype(@) {
|
||||
|
||||
sub new :prototype($$$) {
|
||||
my ($self, $build_id, $step_number, $log_path) = @_;
|
||||
return bless { "build_id" => $build_id, "step_number" => $step_number, "log_path" => $log_path }, $self;
|
||||
|
||||
$log_path = undef if $log_path eq "-";
|
||||
|
||||
return bless {
|
||||
"build_id" => $build_id,
|
||||
"step_number" => $step_number,
|
||||
"log_path" => $log_path,
|
||||
"step" => undef,
|
||||
}, $self;
|
||||
}
|
||||
|
||||
sub load {
|
||||
my ($self, $db) = @_;
|
||||
|
||||
if (!defined($self->{"step"})) {
|
||||
my $build = $db->resultset('Builds')->find($self->{"build_id"})
|
||||
or die "build $self->{'build_id'} does not exist\n";
|
||||
|
||||
$self->{"step"} = $build->buildsteps->find({stepnr => $self->{"step_number"}})
|
||||
or die "step $self->{'step_number'} does not exist\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, $db, $plugin) = @_;
|
||||
|
||||
$self->load($db);
|
||||
|
||||
$plugin->stepFinished($self->{"step"}, $self->{"log_path"});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -75,27 +75,6 @@ sub buildFinished {
|
||||
}
|
||||
}
|
||||
|
||||
sub stepFinished {
|
||||
my ($buildId, $stepNr, $logPath) = @_;
|
||||
|
||||
my $build = $db->resultset('Builds')->find($buildId)
|
||||
or die "build $buildId does not exist\n";
|
||||
|
||||
my $step = $build->buildsteps->find({stepnr => $stepNr})
|
||||
or die "step $stepNr does not exist\n";
|
||||
|
||||
$logPath = undef if $logPath eq "-";
|
||||
|
||||
foreach my $plugin (@plugins) {
|
||||
eval {
|
||||
$plugin->stepFinished($step, $logPath);
|
||||
1;
|
||||
} or do {
|
||||
print STDERR "error with $plugin->stepFinished: $@\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Process builds that finished while hydra-notify wasn't running.
|
||||
for my $build ($db->resultset('Builds')->search(
|
||||
{ notificationpendingsince => { '!=', undef } }))
|
||||
@ -119,14 +98,12 @@ while (!$queued_only) {
|
||||
my @payload = split /\t/, $payload;
|
||||
|
||||
eval {
|
||||
if ($channelName eq "build_started") {
|
||||
if ($channelName eq "build_started" || $channelName eq "step_finished" ) {
|
||||
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]);
|
||||
} elsif ($channelName eq "step_finished") {
|
||||
stepFinished(int($payload[0]), int($payload[1]));
|
||||
}
|
||||
1;
|
||||
} or do {
|
||||
|
Reference in New Issue
Block a user