Tasks: only execute the event if the plugin is interested in it
[?]
Dec 20, 2021, 6:27 PM
USGMELC3GV3KAOQXVKC7XLSLF5UXA7DHI77CX7STJ2BPR5MDRTFACDependencies
- [2]
34SOPSVFAllow to configure the timeout value for the GitInput plugin in different places. - [3]
LM2LEJNHhydra-notify: listen for build_queued events - [4]
6HMHT4IQTaskDispatcher: pre-declare the notify_no_such_plugin metric - [5]
CKYPPACOHopefully fix UTF-8 chars in Hipchat notification messages - [6]
BLVQGJ4LUse OO-style plugins - [7]
FCTX433OAdd buildStarted plugin hook - [8]
NTEDD7T4Provide a plugin hook for when build steps finish - [9]
5EQYVRWEAdd a plugin mechanism - [10]
JAH3UPWASupport revision control systems via plugins - [11]
PXTSKX4GAdd buildQueued plugin hook - [12]
7EGUBBRQLock paths in the scm cache - [*]
EKHD4I44Event: init structure and parse existing messages - [*]
T3OHZDYPhydra-notify: move BuildFinished processing to an Event - [*]
OPSWSU4Lhydra-notify: move BuildStarted processing to an Event - [*]
LQEYBAELhydra-notify: move StepFinished processing to an Event - [*]
GQGQEMMAEvent.pm: add a new_event helper to parse and construct an Event - [*]
SWXGVPJNhydra-notify: extract runPluginsForEvent to a TaskDispatcher
Change contents
- edit in src/lib/Hydra/Event/BuildFinished.pm at line 30
sub interestedIn {my ($self, $plugin) = @_;return int(defined($plugin->can('buildFinished')));} - edit in src/lib/Hydra/Event/BuildQueued.pm at line 28
sub interestedIn {my ($self, $plugin) = @_;return int(defined($plugin->can('buildQueued')));} - edit in src/lib/Hydra/Event/BuildStarted.pm at line 28
sub interestedIn {my ($self, $plugin) = @_;return int(defined($plugin->can('buildStarted')));} - edit in src/lib/Hydra/Event/StepFinished.pm at line 37
sub interestedIn {my ($self, $plugin) = @_;return int(defined($plugin->can('stepFinished')));} - edit in src/lib/Hydra/Event.pm at line 39
}sub interested {my ($self, $plugin) = @_;return $self->{"event"}->interestedIn($plugin); - edit in src/lib/Hydra/Plugin/GitInput.pm at line 17
- replacement in src/lib/Hydra/Plugin.pm at line 28
# Called when build $build has been queued.sub buildQueued {my ($self, $build) = @_;}# To implement behaviors in response to the following events, implement# the function in your plugin and it will be executed by hydra-notify.## See the tests in t/Event/*.t for arguments, and the documentation for# notify events for semantics.## # Called when build $build has been queued.# sub buildQueued {# my ($self, $build) = @_;# } - replacement in src/lib/Hydra/Plugin.pm at line 39
# Called when build $build has started.sub buildStarted {my ($self, $build) = @_;}# # Called when build $build has started.# sub buildStarted {# my ($self, $build) = @_;# } - replacement in src/lib/Hydra/Plugin.pm at line 44[5.1573]→[5.6078:6304](∅→∅),[5.6078]→[5.6078:6304](∅→∅),[5.6304]→[5.461:523](∅→∅),[5.523]→[5.3495:3497](∅→∅)
# Called when build $build has finished. If the build failed, then# $dependents is an array ref to a list of builds that have also# failed as a result (i.e. because they depend on $build or a failed# dependeny of $build).sub buildFinished {my ($self, $build, $dependents) = @_;}# # Called when build $build has finished. If the build failed, then# # $dependents is an array ref to a list of builds that have also# # failed as a result (i.e. because they depend on $build or a failed# # dependeny of $build).# sub buildFinished {# my ($self, $build, $dependents) = @_;# } - replacement in src/lib/Hydra/Plugin.pm at line 52
# Called when step $step has finished. The build log is stored in the# file $logPath (bzip2-compressed).sub stepFinished {my ($self, $step, $logPath) = @_;}# # Called when step $step has finished. The build log is stored in the# # file $logPath (bzip2-compressed).# sub stepFinished {# my ($self, $step, $logPath) = @_;# } - edit in src/lib/Hydra/TaskDispatcher.pm at line 119
);$prometheus->declare("notify_plugin_not_interested",type => "counter",help => "Number of tasks that have not been processed because the plugin was not interested in the event." - edit in src/lib/Hydra/TaskDispatcher.pm at line 198[19.3465][19.3465]
if (!$task->{"event"}->interested($plugin)) {$self->{"prometheus"}->inc("notify_plugin_not_interested", $event_labels);return 0;} - edit in t/Event/BuildFinished.t at line 56
subtest "interested" => sub {my $event = Hydra::Event::BuildFinished->new(123, []);subtest "A plugin which does not implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => ();is($event->interestedIn($plugin), 0, "The plugin is not interesting.");};subtest "A plugin which does implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => (add => ["buildFinished" => sub {}]); - edit in t/Event/BuildFinished.t at line 75
is($event->interestedIn($plugin), 1, "The plugin is interesting.");};}; - edit in t/Event/BuildQueued.t at line 40
};subtest "interested" => sub {my $event = Hydra::Event::BuildQueued->new(123, []);subtest "A plugin which does not implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => ();is($event->interestedIn($plugin), 0, "The plugin is not interesting.");};subtest "A plugin which does implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => (add => ["buildQueued" => sub {}]);is($event->interestedIn($plugin), 1, "The plugin is interesting.");}; - edit in t/Event/BuildStarted.t at line 46
};subtest "interested" => sub {my $event = Hydra::Event::BuildStarted->new(123, []);subtest "A plugin which does not implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => ();is($event->interestedIn($plugin), 0, "The plugin is not interesting.");};subtest "A plugin which does implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => (add => ["buildStarted" => sub {}]);is($event->interestedIn($plugin), 1, "The plugin is interesting.");}; - edit in t/Event/StepFinished.t at line 65
};subtest "interested" => sub {my $event = Hydra::Event::StepFinished->new(123, []);subtest "A plugin which does not implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => ();is($event->interestedIn($plugin), 0, "The plugin is not interesting.");};subtest "A plugin which does implement the API" => sub {my $plugin = {};my $mock = mock_obj $plugin => (add => ["stepFinished" => sub {}]);is($event->interestedIn($plugin), 1, "The plugin is interesting.");};