forked from lix-project/hydra
Call buildFinished when a cached build is added
Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
b46f2134e0
commit
166d56088f
|
@ -575,7 +575,7 @@ sub clone_submit : Chained('buildChain') PathPart('clone/submit') Args(0) {
|
||||||
my %currentBuilds;
|
my %currentBuilds;
|
||||||
my $newBuild = checkBuild(
|
my $newBuild = checkBuild(
|
||||||
$c->model('DB'), $build->project, $build->jobset,
|
$c->model('DB'), $build->project, $build->jobset,
|
||||||
$inputInfo, $nixExprInput, $job, \%currentBuilds, undef, {});
|
$inputInfo, $nixExprInput, $job, \%currentBuilds, undef, {}, $c->hydra_plugins);
|
||||||
|
|
||||||
error($c, "This build has already been performed.") unless $newBuild;
|
error($c, "This build has already been performed.") unless $newBuild;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ use File::Path;
|
||||||
use File::Temp;
|
use File::Temp;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use File::Slurp;
|
use File::Slurp;
|
||||||
|
use Hydra::Helper::PluginHooks;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
|
@ -389,7 +390,7 @@ sub getPrevJobsetEval {
|
||||||
|
|
||||||
# Check whether to add the build described by $buildInfo.
|
# Check whether to add the build described by $buildInfo.
|
||||||
sub checkBuild {
|
sub checkBuild {
|
||||||
my ($db, $project, $jobset, $inputInfo, $nixExprInput, $buildInfo, $buildIds, $prevEval, $jobOutPathMap) = @_;
|
my ($db, $project, $jobset, $inputInfo, $nixExprInput, $buildInfo, $buildIds, $prevEval, $jobOutPathMap, $plugins) = @_;
|
||||||
|
|
||||||
my @outputNames = sort keys %{$buildInfo->{output}};
|
my @outputNames = sort keys %{$buildInfo->{output}};
|
||||||
die unless scalar @outputNames;
|
die unless scalar @outputNames;
|
||||||
|
@ -517,6 +518,7 @@ sub checkBuild {
|
||||||
if ($build->iscachedbuild) {
|
if ($build->iscachedbuild) {
|
||||||
print STDERR " marked as cached build ", $build->id, "\n";
|
print STDERR " marked as cached build ", $build->id, "\n";
|
||||||
addBuildProducts($db, $build);
|
addBuildProducts($db, $build);
|
||||||
|
notifyBuildFinished($plugins, $build, []);
|
||||||
} else {
|
} else {
|
||||||
print STDERR " added to queue as build ", $build->id, "\n";
|
print STDERR " added to queue as build ", $build->id, "\n";
|
||||||
}
|
}
|
||||||
|
|
22
src/lib/Hydra/Helper/PluginHooks.pm
Normal file
22
src/lib/Hydra/Helper/PluginHooks.pm
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package Hydra::Helper::PluginHooks;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Exporter;
|
||||||
|
|
||||||
|
our @ISA = qw(Exporter);
|
||||||
|
our @EXPORT = qw(
|
||||||
|
notifyBuildFinished);
|
||||||
|
|
||||||
|
sub notifyBuildFinished {
|
||||||
|
my ($plugins, $build, $dependents) = @_;
|
||||||
|
foreach my $plugin (@{$plugins}) {
|
||||||
|
eval {
|
||||||
|
$plugin->buildFinished($build, $dependents);
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
print STDERR "$plugin->buildFinished: $@\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -8,6 +8,7 @@ use Nix::Store;
|
||||||
use Hydra::Plugin;
|
use Hydra::Plugin;
|
||||||
use Hydra::Schema;
|
use Hydra::Schema;
|
||||||
use Hydra::Helper::Nix;
|
use Hydra::Helper::Nix;
|
||||||
|
use Hydra::Helper::PluginHooks;
|
||||||
use Hydra::Model::DB;
|
use Hydra::Model::DB;
|
||||||
use Hydra::Helper::AddBuilds;
|
use Hydra::Helper::AddBuilds;
|
||||||
|
|
||||||
|
@ -80,19 +81,6 @@ sub failDependents {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub notify {
|
|
||||||
my ($build, $dependents) = @_;
|
|
||||||
foreach my $plugin (@plugins) {
|
|
||||||
eval {
|
|
||||||
$plugin->buildFinished($build, $dependents);
|
|
||||||
};
|
|
||||||
if ($@) {
|
|
||||||
print STDERR "$plugin->buildFinished: $@\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub doBuild {
|
sub doBuild {
|
||||||
my ($build) = @_;
|
my ($build) = @_;
|
||||||
|
|
||||||
|
@ -319,7 +307,7 @@ sub doBuild {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
notify($build, $dependents);
|
notifyBuildFinished(\@plugins, $build, $dependents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,7 +316,7 @@ print STDERR "performing build $buildId\n";
|
||||||
|
|
||||||
if ($ENV{'HYDRA_MAIL_TEST'}) {
|
if ($ENV{'HYDRA_MAIL_TEST'}) {
|
||||||
my $build = $db->resultset('Builds')->find($buildId);
|
my $build = $db->resultset('Builds')->find($buildId);
|
||||||
notify($build, []);
|
notifyBuildFinished(\@plugins, $build, []);
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ sub checkJobsetWrapped {
|
||||||
foreach my $job (permute @{$jobs->{job}}) {
|
foreach my $job (permute @{$jobs->{job}}) {
|
||||||
next if $job->{jobName} eq "";
|
next if $job->{jobName} eq "";
|
||||||
print STDERR " considering job " . $project->name, ":", $jobset->name, ":", $job->{jobName} . "\n";
|
print STDERR " considering job " . $project->name, ":", $jobset->name, ":", $job->{jobName} . "\n";
|
||||||
checkBuild($db, $project, $jobset, $inputInfo, $nixExprInput, $job, \%buildIds, $prevEval, $jobOutPathMap);
|
checkBuild($db, $project, $jobset, $inputInfo, $nixExprInput, $job, \%buildIds, $prevEval, $jobOutPathMap, $plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update the last checked times and error messages for each
|
# Update the last checked times and error messages for each
|
||||||
|
|
Loading…
Reference in a new issue