From 582c39942097539aa595d6945a82c4e25ca16ff1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 24 May 2017 09:45:31 -0400 Subject: [PATCH] Add buildQueued plugin hook --- src/lib/Hydra/Plugin.pm | 5 +++++ src/lib/Hydra/Plugin/GithubStatus.pm | 4 ++++ src/script/hydra-eval-jobset | 1 + src/script/hydra-notify | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/src/lib/Hydra/Plugin.pm b/src/lib/Hydra/Plugin.pm index a00ab5ba..8177d9ce 100644 --- a/src/lib/Hydra/Plugin.pm +++ b/src/lib/Hydra/Plugin.pm @@ -20,6 +20,11 @@ sub instantiate { return @$plugins; } +# Called when build $build has been queued. +sub buildQueued { + my ($self, $build) = @_; +} + # Called when build $build has started. sub buildStarted { my ($self, $build) = @_; diff --git a/src/lib/Hydra/Plugin/GithubStatus.pm b/src/lib/Hydra/Plugin/GithubStatus.pm index 136c7100..35b53472 100644 --- a/src/lib/Hydra/Plugin/GithubStatus.pm +++ b/src/lib/Hydra/Plugin/GithubStatus.pm @@ -69,6 +69,10 @@ sub common { } } +sub buildQueued { + common(@_, [], 0); +} + sub buildStarted { common(@_, [], 0); } diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset index 2025404f..87095e79 100755 --- a/src/script/hydra-eval-jobset +++ b/src/script/hydra-eval-jobset @@ -471,6 +471,7 @@ sub checkBuild { print STDERR "added build ${\$build->id} (${\$jobset->project->name}:${\$jobset->name}:$jobName)\n"; }); + system("hydra-notify build-queued " . $build->id) if defined $buildMap->{$build->id} && $buildMap->{$build->id}->{new}; return $build; }; diff --git a/src/script/hydra-notify b/src/script/hydra-notify index b0984e8e..9cbc885f 100755 --- a/src/script/hydra-notify +++ b/src/script/hydra-notify @@ -42,6 +42,15 @@ if ($cmd eq "build-finished") { } } +elsif ($cmd eq "build-queued") { + foreach my $plugin (@plugins) { + eval { $plugin->buildQueued($build); }; + if ($@) { + print STDERR "$plugin->buildQueued: $@\n"; + } + } +} + elsif ($cmd eq "build-started") { foreach my $plugin (@plugins) { eval { $plugin->buildStarted($build); };