forked from lix-project/hydra
RunCommand: Allow displaying command output
This commit is contained in:
parent
4cb5e6cd94
commit
796ce165d4
|
@ -137,6 +137,15 @@ sub view_log : Chained('buildChain') PathPart('log') {
|
|||
}
|
||||
|
||||
|
||||
sub view_runcommand_log : Chained('buildChain') PathPart('runcommand-log') {
|
||||
my ($self, $c, $sha) = @_;
|
||||
|
||||
$c->stash->{is_runcommand} = 1;
|
||||
$c->stash->{log_uri} = $c->uri_for($c->controller('Root')->action_for("runcommandlog"), $sha . "-" . $c->stash->{build}->id);
|
||||
$c->stash->{template} = 'log.tt';
|
||||
}
|
||||
|
||||
|
||||
sub showLog {
|
||||
my ($c, $mode, $finished, $drvPath) = @_;
|
||||
$mode //= "pretty";
|
||||
|
|
|
@ -7,6 +7,7 @@ use base 'Hydra::Base::Controller::ListBuilds';
|
|||
use Hydra::Helper::Nix;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
use Hydra::View::TT;
|
||||
use Hydra::Model::DB;
|
||||
use Nix::Store;
|
||||
use Nix::Config;
|
||||
use Encode;
|
||||
|
@ -530,4 +531,20 @@ sub log :Local :Args(1) {
|
|||
}
|
||||
}
|
||||
|
||||
sub runcommandlog :Local :Args(1) {
|
||||
my ($self, $c, $filename) = @_;
|
||||
|
||||
my $tail = $c->request->params->{"tail"};
|
||||
|
||||
die if defined $tail && $tail !~ /^[0-9]+$/;
|
||||
|
||||
my $logFile = Hydra::Model::DB::getHydraPath . "/runcommand-logs/" . substr($filename, 0, 2) . "/$filename";
|
||||
if (-f $logFile) {
|
||||
serveLogFile($c, $logFile, $tail);
|
||||
return;
|
||||
} else {
|
||||
notFound($c, "The RunCommand log is not available.");
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -152,6 +152,8 @@ __PACKAGE__->belongs_to(
|
|||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9AIzlQl1RjRXrs9gQCZKVw
|
||||
|
||||
use POSIX qw(WEXITSTATUS WIFEXITED WIFSIGNALED WTERMSIG);
|
||||
use Digest::SHA1 qw(sha1_hex);
|
||||
use Hydra::Model::DB;
|
||||
|
||||
=head2 started
|
||||
|
||||
|
@ -321,3 +323,29 @@ sub did_fail_with_exec_error {
|
|||
}
|
||||
|
||||
1;
|
||||
|
||||
=head2 log_relative_url
|
||||
|
||||
Returns the URL to the log file relative to the build it belongs to.
|
||||
|
||||
Return:
|
||||
|
||||
* The relative URL if a log file exists
|
||||
* An empty string otherwise
|
||||
=cut
|
||||
sub log_relative_url() {
|
||||
my ($self) = @_;
|
||||
|
||||
# Do not return a URL when there is no build yet
|
||||
if (not defined($self->start_time)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
my $sha = sha1_hex($self->command);
|
||||
# Do not return a URL when there is no log file yet
|
||||
if (not -f Hydra::Model::DB::getHydraPath . "/runcommand-logs/" . substr($sha, 0, 2) . "/$sha-" . $self->build_id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "runcommand-log/$sha";
|
||||
}
|
||||
|
|
|
@ -525,9 +525,9 @@ END;
|
|||
[% IF runcommandlog.start_time != undef %]
|
||||
<div>Started at [% INCLUDE renderDateTime timestamp = runcommandlog.start_time; %]</div>
|
||||
[% IF runcommandlog.end_time != undef %]
|
||||
<div>Ran for [% INCLUDE renderDuration duration = runcommandlog.end_time - runcommandlog.start_time %]</div>
|
||||
<div>Ran for [% INCLUDE renderDuration duration = runcommandlog.end_time - runcommandlog.start_time %][% IF runcommandlog.log_relative_url() %] — <a href="[% c.uri_for('/build', build.id, runcommandlog.log_relative_url()) %]">Logs</a>[% END %]</div>
|
||||
[% ELSE %]
|
||||
<div>Running for [% INCLUDE renderDuration duration = curTime - runcommandlog.start_time %]</div>
|
||||
<div>Running for [% INCLUDE renderDuration duration = curTime - runcommandlog.start_time %][% IF runcommandlog.log_relative_url() %] — <a href="[% c.uri_for('/build', build.id, runcommandlog.log_relative_url()) %]">Logs</a>[% END %]</div>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<div>Pending</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[% WRAPPER layout.tt
|
||||
titleHTML="Log of " _ (step ? " step $step.stepnr of " : "") _ "build ${build.id} of job " _ linkToJob(build.jobset, job)
|
||||
title="Log of " _ (step ? " step $step.stepnr of " : "") _ "build ${build.id} of job " _ makeNameTextForJob(build.jobset, job)
|
||||
titleHTML=(is_runcommand ? "RunCommand log of " : "Log of ") _ (step ? " step $step.stepnr of " : "") _ "build ${build.id} of job " _ linkToJob(build.jobset, job)
|
||||
title=(is_runcommand ? "RunCommand log of " : "Log of ") _ (step ? " step $step.stepnr of " : "") _ "build ${build.id} of job " _ makeNameTextForJob(build.jobset, job)
|
||||
%]
|
||||
[% PROCESS common.tt %]
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
|||
[% ELSE %]
|
||||
is
|
||||
[% END %]
|
||||
the build log of derivation <tt>[% IF step; step.drvpath; ELSE; build.drvpath; END %]</tt>.
|
||||
[% IF is_runcommand %] the output of a RunCommand execution of[% ELSE %] the build log of[% END %] derivation <tt>[% IF step; step.drvpath; ELSE; build.drvpath; END %]</tt>.
|
||||
[% IF step && step.machine %]
|
||||
It was built on <tt>[% step.machine %]</tt>.
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue