Support revision control systems via plugins
This commit is contained in:
@ -11,6 +11,7 @@ use Hydra::Model::DB;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
getHydraHome getHydraConfig txn_do
|
||||
getSCMCacheDir
|
||||
registerRoot getGCRootsDir gcRootFor
|
||||
getPrimaryBuildsForView
|
||||
getPrimaryBuildTotal
|
||||
@ -18,7 +19,8 @@ our @EXPORT = qw(
|
||||
jobsetOverview removeAsciiEscapes getDrvLogPath logContents
|
||||
getMainOutput
|
||||
getEvals getMachines
|
||||
pathIsInsidePrefix);
|
||||
pathIsInsidePrefix
|
||||
captureStdoutStderr);
|
||||
|
||||
|
||||
sub getHydraHome {
|
||||
@ -50,6 +52,11 @@ sub txn_do {
|
||||
}
|
||||
|
||||
|
||||
sub getSCMCacheDir {
|
||||
return Hydra::Model::DB::getHydraPath . "/scm" ;
|
||||
}
|
||||
|
||||
|
||||
sub getGCRootsDir {
|
||||
die unless defined $ENV{LOGNAME};
|
||||
my $dir = ($ENV{NIX_STATE_DIR} || "/nix/var/nix" ) . "/gcroots/per-user/$ENV{LOGNAME}/hydra-roots";
|
||||
@ -443,4 +450,26 @@ sub pathIsInsidePrefix {
|
||||
}
|
||||
|
||||
|
||||
sub captureStdoutStderr {
|
||||
my ($timeout, @cmd) = @_;
|
||||
my $stdin = "";
|
||||
my $stdout;
|
||||
my $stderr;
|
||||
|
||||
eval {
|
||||
local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n required
|
||||
alarm $timeout;
|
||||
IPC::Run::run(\@cmd, \$stdin, \$stdout, \$stderr);
|
||||
alarm 0;
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
die unless $@ eq "timeout\n"; # propagate unexpected errors
|
||||
return (-1, "", "timeout\n");
|
||||
} else {
|
||||
return ($?, $stdout, $stderr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user