hydra-notify: move StepFinished processing to an Event

This commit is contained in:
Graham Christensen
2021-08-12 10:28:35 -04:00
committed by Your Name
parent 4fdb20d3bd
commit 4a1389e36e
4 changed files with 133 additions and 63 deletions

View File

@ -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;