forked from lix-project/hydra
hydra: factored out build restart and
This commit is contained in:
parent
02856780cf
commit
6d6f43fa0c
|
@ -357,26 +357,12 @@ sub restart : Chained('build') PathPart Args(0) {
|
|||
my $build = $c->stash->{build};
|
||||
|
||||
requireProjectOwner($c, $build->project);
|
||||
|
||||
my $drvpath = $build->drvpath ;
|
||||
error($c, "This build cannot be restarted.")
|
||||
unless $build->finished && -f $drvpath ;
|
||||
|
||||
txn_do($c->model('DB')->schema, sub {
|
||||
my $drvpath = $build->drvpath ;
|
||||
error($c, "This build cannot be restarted.")
|
||||
unless $build->finished && -f $drvpath ;
|
||||
|
||||
my $cmd = "`nix-store -qR $drvpath`";
|
||||
my $r = `nix-store --clear-failed-paths $cmd`;
|
||||
|
||||
$build->update({finished => 0, timestamp => time});
|
||||
|
||||
$build->resultInfo->delete;
|
||||
|
||||
$c->model('DB::BuildSchedulingInfo')->create(
|
||||
{ id => $build->id
|
||||
, priority => 0 # don't know the original priority anymore...
|
||||
, busy => 0
|
||||
, locker => ""
|
||||
});
|
||||
});
|
||||
restartBuild($build);
|
||||
|
||||
$c->flash->{buildMsg} = "Build has been restarted.";
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use File::stat;
|
|||
use File::Path;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr getReleaseName getBuildLog addBuildProducts);
|
||||
our @EXPORT = qw(fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr getReleaseName getBuildLog addBuildProducts restartBuild);
|
||||
|
||||
sub scmPath {
|
||||
return getHydraPath . "/scm" ;
|
||||
|
@ -764,3 +764,30 @@ sub checkBuild {
|
|||
|
||||
return $build;
|
||||
};
|
||||
|
||||
|
||||
sub restartBuild {
|
||||
my ($db, $build) = @_;
|
||||
|
||||
txn_do($db, sub {
|
||||
my $drvpath = $build->drvpath ;
|
||||
my $outpath = $build->outpath ;
|
||||
|
||||
my $paths = "";
|
||||
foreach my $bs ($build->buildsteps) {
|
||||
$paths = $paths . " " . $bs->outpath;
|
||||
}
|
||||
|
||||
my $r = `nix-store --clear-failed-paths $paths $outpath`;
|
||||
$build->update({finished => 0, timestamp => time});
|
||||
|
||||
$build->resultInfo->delete;
|
||||
|
||||
$db->resultset('BuildSchedulingInfo')->create(
|
||||
{ id => $build->id
|
||||
, priority => 0 # don't know the original priority anymore...
|
||||
, busy => 0
|
||||
, locker => ""
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue