Call buildFinished when a cached build is added

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-07-08 13:35:34 -04:00
parent b46f2134e0
commit 166d56088f
5 changed files with 30 additions and 18 deletions

View file

@ -575,7 +575,7 @@ sub clone_submit : Chained('buildChain') PathPart('clone/submit') Args(0) {
my %currentBuilds;
my $newBuild = checkBuild(
$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;

View file

@ -15,6 +15,7 @@ use File::Path;
use File::Temp;
use File::Spec;
use File::Slurp;
use Hydra::Helper::PluginHooks;
our @ISA = qw(Exporter);
our @EXPORT = qw(
@ -389,7 +390,7 @@ sub getPrevJobsetEval {
# Check whether to add the build described by $buildInfo.
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}};
die unless scalar @outputNames;
@ -517,6 +518,7 @@ sub checkBuild {
if ($build->iscachedbuild) {
print STDERR " marked as cached build ", $build->id, "\n";
addBuildProducts($db, $build);
notifyBuildFinished($plugins, $build, []);
} else {
print STDERR " added to queue as build ", $build->id, "\n";
}

View 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;

View file

@ -8,6 +8,7 @@ use Nix::Store;
use Hydra::Plugin;
use Hydra::Schema;
use Hydra::Helper::Nix;
use Hydra::Helper::PluginHooks;
use Hydra::Model::DB;
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 {
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'}) {
my $build = $db->resultset('Builds')->find($buildId);
notify($build, []);
notifyBuildFinished(\@plugins, $build, []);
exit 0;
}

View file

@ -148,7 +148,7 @@ sub checkJobsetWrapped {
foreach my $job (permute @{$jobs->{job}}) {
next if $job->{jobName} eq "";
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