forked from lix-project/hydra
Plugins: Add isEnabled method
Plugins are now disabled at startup time unless there is some relevant configuration in hydra.conf. This avoids hydra-notify having to do a lot of redundant work (a lot of plugins did a lot of database queries *before* deciding they were disabled). Note: BitBucketStatus users will need to add 'enable_bitbucket_status = 1' to hydra.conf.
This commit is contained in:
parent
f49a089fc0
commit
16811d3e78
|
@ -12,11 +12,15 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub isEnabled {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub instantiate {
|
||||
my ($class, %args) = @_;
|
||||
my $plugins = [];
|
||||
$args{plugins} = $plugins;
|
||||
push @$plugins, $class->plugins(%args);
|
||||
push @$plugins, grep { $_->isEnabled } $class->plugins(%args);
|
||||
return @$plugins;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@ use JSON;
|
|||
use LWP::UserAgent;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return $self->{config}->{enable_bitbucket_status} == 1;
|
||||
}
|
||||
|
||||
sub toBitBucketState {
|
||||
my ($buildStatus) = @_;
|
||||
if ($buildStatus == 0) {
|
||||
|
|
|
@ -7,6 +7,11 @@ use LWP::UserAgent;
|
|||
use Hydra::Helper::CatalystUtils;
|
||||
use JSON;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{circleci};
|
||||
}
|
||||
|
||||
sub buildFinished {
|
||||
my ($self, $build, $dependents) = @_;
|
||||
my $cfg = $self->{config}->{circleci};
|
||||
|
|
|
@ -6,6 +6,11 @@ use File::Basename;
|
|||
use LWP::UserAgent;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{coverityscan};
|
||||
}
|
||||
|
||||
sub buildFinished {
|
||||
my ($self, $b, $dependents) = @_;
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ use Hydra::Helper::Nix;
|
|||
use Hydra::Helper::CatalystUtils;
|
||||
use Hydra::Helper::Email;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return $self->{config}->{email_notification} == 1;
|
||||
}
|
||||
|
||||
my $template = <<EOF;
|
||||
Hi,
|
||||
|
@ -44,8 +48,6 @@ EOF
|
|||
sub buildFinished {
|
||||
my ($self, $build, $dependents) = @_;
|
||||
|
||||
return unless $self->{config}->{email_notification} // 0;
|
||||
|
||||
die unless $build->finished;
|
||||
|
||||
# Figure out to whom to send notification for each build. For
|
||||
|
|
|
@ -8,6 +8,11 @@ use LWP::UserAgent;
|
|||
use Hydra::Helper::CatalystUtils;
|
||||
use List::Util qw(max);
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{githubstatus};
|
||||
}
|
||||
|
||||
sub toGithubState {
|
||||
my ($buildStatus) = @_;
|
||||
if ($buildStatus == 0) {
|
||||
|
|
|
@ -16,6 +16,11 @@ use List::Util qw(max);
|
|||
# - gitlab_project_id => ID of the project in Gitlab, i.e. in the above
|
||||
# case the ID in gitlab of "nixexprs"
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{gitlab_authorization};
|
||||
}
|
||||
|
||||
sub toGitlabState {
|
||||
my ($status, $buildStatus) = @_;
|
||||
if ($status == 0) {
|
||||
|
|
|
@ -5,6 +5,11 @@ use parent 'Hydra::Plugin';
|
|||
use LWP::UserAgent;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{hipchat};
|
||||
}
|
||||
|
||||
sub buildFinished {
|
||||
my ($self, $build, $dependents) = @_;
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@ use HTTP::Request;
|
|||
use LWP::UserAgent;
|
||||
# use Hydra::Helper::CatalystUtils;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{influxdb};
|
||||
}
|
||||
|
||||
sub toBuildStatusDetailed {
|
||||
my ($buildStatus) = @_;
|
||||
if ($buildStatus == 0) {
|
||||
|
|
|
@ -5,6 +5,11 @@ use parent 'Hydra::Plugin';
|
|||
use experimental 'smartmatch';
|
||||
use JSON;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{runcommand};
|
||||
}
|
||||
|
||||
sub configSectionMatches {
|
||||
my ($name, $project, $jobset, $job) = @_;
|
||||
|
||||
|
|
|
@ -14,6 +14,11 @@ use Nix::Store;
|
|||
use Hydra::Model::DB;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{s3backup};
|
||||
}
|
||||
|
||||
my $client;
|
||||
my %compressors = (
|
||||
xz => "| $Nix::Config::xz",
|
||||
|
|
|
@ -7,6 +7,11 @@ use LWP::UserAgent;
|
|||
use Hydra::Helper::CatalystUtils;
|
||||
use JSON;
|
||||
|
||||
sub isEnabled {
|
||||
my ($self) = @_;
|
||||
return defined $self->{config}->{slack};
|
||||
}
|
||||
|
||||
sub renderDuration {
|
||||
my ($build) = @_;
|
||||
my $duration = $build->stoptime - $build->starttime;
|
||||
|
|
Loading…
Reference in a new issue