This is mostly so we don't have to pass around common parameters like "db" and "config", and we don't have to check for the existence of methods. A plugin now looks like this: package Hydra::Plugin::TwitterNotification; use parent 'Hydra::Plugin'; sub buildFinished { my ($self, $build, $dependents) = @_; print STDERR "tweeting about build ", $build->id, "\n"; # Send tweet... # Hydra database is $self->{db}. }
24 lines
561 B
Perl
24 lines
561 B
Perl
package Hydra::Plugin;
|
|
|
|
use strict;
|
|
use Module::Pluggable
|
|
search_path => "Hydra::Plugin",
|
|
instantiate => 'new';
|
|
|
|
sub new {
|
|
my ($class, %args) = @_;
|
|
my $self = { db => $args{db}, config => $args{config} };
|
|
bless $self, $class;
|
|
return $self;
|
|
}
|
|
|
|
# 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) = @_;
|
|
}
|
|
|
|
1;
|