diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 977b92f9..01fa7cb4 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -10,7 +10,7 @@ use Digest::SHA qw(sha256_hex); use File::Path; our @ISA = qw(Exporter); -our @EXPORT = qw(fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr); +our @EXPORT = qw(fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr getReleaseName); sub scmPath { return getHydraPath . "/scm" ; @@ -29,6 +29,18 @@ sub getStorePathHash { return $hash; } +sub getReleaseName { + my ($outPath) = @_; + + my $releaseName; + if (-e "$outPath/nix-support/hydra-release-name") { + open FILE, "$outPath/nix-support/hydra-release-name" or die; + $releaseName = ; + chomp $releaseName; + close FILE; + } + return $releaseName; +} sub parseJobName { # Parse a job specification of the form `:: @@ -607,10 +619,12 @@ sub checkBuild { return; } + my $time = time(); + # Nope, so add it. $build = $job->builds->create( { finished => 0 - , timestamp => time() + , timestamp => $time , description => $buildInfo->{description} , longdescription => $buildInfo->{longDescription} , license => $buildInfo->{license} @@ -627,15 +641,29 @@ sub checkBuild { , nixexprpath => $jobset->nixexprpath }); - print STDERR "added to queue as build ", $build->id, "\n"; $currentBuilds->{$build->id} = 1; - $build->create_related('buildschedulinginfo', - { priority => $priority - , busy => 0 - , locker => "" - }); + if(isValidPath($outPath)) { + print STDERR "marked as cached build ", $build->id, "\n"; + $build->update({ finished => 1 }); + $build->create_related('buildresultinfo', + { iscachedbuild => 1 + , buildstatus => 0 + , starttime => $time + , stoptime => $time + , logfile => getBuildLog($drvPath) + , errormsg => "" + , releasename => getReleaseName($outPath) + }); + } else { + print STDERR "added to queue as build ", $build->id, "\n"; + $build->create_related('buildschedulinginfo', + { priority => $priority + , busy => 0 + , locker => "" + }); + } my %inputs; $inputs{$jobset->nixexprinput} = $nixExprInput; diff --git a/src/script/hydra_build.pl b/src/script/hydra_build.pl index d4ff9857..24224c7a 100755 --- a/src/script/hydra_build.pl +++ b/src/script/hydra_build.pl @@ -83,7 +83,7 @@ sub sendEmailNotification { die unless defined $build->resultInfo; - return if ! ( $build->jobset->enableemail && ($build->maintainers neq "" || $build->jobset->emailoverride neq "") ); + return if ! ( $build->jobset->enableemail && ($build->maintainers ne "" || $build->jobset->emailoverride ne "") ); # Do we want to send mail? @@ -376,13 +376,7 @@ sub doBuild { txn_do($db, sub { $build->update({finished => 1, timestamp => time}); - my $releaseName; - if (-e "$outPath/nix-support/hydra-release-name") { - open FILE, "$outPath/nix-support/hydra-release-name" or die; - $releaseName = ; - chomp $releaseName; - close FILE; - } + my $releaseName = getReleaseName($outPath); $db->resultset('BuildResultInfo')->create( { id => $build->id