forked from lix-project/hydra
Merge pull request #590 from Taneb/one-runcommand
Allow for precisely one instance of RunCommand plugin
This commit is contained in:
commit
b15288bea4
|
@ -25,8 +25,8 @@ sub configSectionMatches {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub eventMatches {
|
sub eventMatches {
|
||||||
my ($cfg, $event) = @_;
|
my ($conf, $event) = @_;
|
||||||
for my $x (split " ", ($cfg->{events} // "buildFinished")) {
|
for my $x (split " ", ($conf->{events} // "buildFinished")) {
|
||||||
return 1 if $x eq $event;
|
return 1 if $x eq $event;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -36,19 +36,20 @@ sub buildFinished {
|
||||||
my ($self, $build, $dependents) = @_;
|
my ($self, $build, $dependents) = @_;
|
||||||
my $event = "buildFinished";
|
my $event = "buildFinished";
|
||||||
|
|
||||||
my $config = $self->{config}->{runcommand} // [];
|
my $cfg = $self->{config}->{runcommand};
|
||||||
|
my @config = defined $cfg ? ref $cfg eq "ARRAY" ? @$cfg : ($cfg) : ();
|
||||||
|
|
||||||
my $tmp;
|
my $tmp;
|
||||||
|
|
||||||
foreach my $cfg (@$config) {
|
foreach my $conf (@config) {
|
||||||
next unless eventMatches($cfg, $event);
|
next unless eventMatches($conf, $event);
|
||||||
next unless configSectionMatches(
|
next unless configSectionMatches(
|
||||||
$cfg->{job} // "*:*:*",
|
$conf->{job} // "*:*:*",
|
||||||
$build->get_column('project'),
|
$build->get_column('project'),
|
||||||
$build->get_column('jobset'),
|
$build->get_column('jobset'),
|
||||||
$build->get_column('job'));
|
$build->get_column('job'));
|
||||||
|
|
||||||
my $command = $cfg->{command} // die "<runcommand> section lacks a 'command' option";
|
my $command = $conf->{command} // die "<runcommand> section lacks a 'command' option";
|
||||||
|
|
||||||
unless (defined $tmp) {
|
unless (defined $tmp) {
|
||||||
$tmp = File::Temp->new(SUFFIX => '.json');
|
$tmp = File::Temp->new(SUFFIX => '.json');
|
||||||
|
|
Loading…
Reference in a new issue