diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 9a2c5607..d02c66a4 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -137,10 +137,10 @@ sub view_log : Chained('buildChain') PathPart('log') { } -sub view_runcommand_log : Chained('buildChain') PathPart('runcommand-log') { - my ($self, $c, $sha) = @_; +sub view_runcommandlog : Chained('buildChain') PathPart('runcommandlog') { + my ($self, $c, $uuid) = @_; - $c->stash->{log_uri} = $c->uri_for($c->controller('Root')->action_for("runcommandlog"), constructRunCommandLogFilename($sha, $c->stash->{build}->id)); + $c->stash->{log_uri} = $c->uri_for($c->controller('Root')->action_for("runcommandlog"), $uuid); $c->stash->{template} = 'runcommand-log.tt'; } diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 81f79378..2683d6c9 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -531,13 +531,13 @@ sub log :Local :Args(1) { } sub runcommandlog :Local :Args(1) { - my ($self, $c, $filename) = @_; + my ($self, $c, $uuid) = @_; my $tail = $c->request->params->{"tail"}; die if defined $tail && $tail !~ /^[0-9]+$/; - my $logFile = constructRunCommandLogPath($filename); + my $logFile = constructRunCommandLogPath($uuid); if (-f $logFile) { serveLogFile($c, $logFile, $tail); return; diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index a58e638d..d2c4908c 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -19,7 +19,6 @@ our @EXPORT = qw( cancelBuilds captureStdoutStderr captureStdoutStderrWithStdin - constructRunCommandLogFilename constructRunCommandLogPath findLog gcRootFor @@ -591,13 +590,6 @@ sub isLocalStore { } -sub constructRunCommandLogFilename { - my ($sha, $build_id) = @_; - my $filename = "$sha-$build_id"; - return $filename; -} - - sub constructRunCommandLogPath { my ($filename) = @_; diff --git a/src/lib/Hydra/Plugin/RunCommand.pm b/src/lib/Hydra/Plugin/RunCommand.pm index 94ed5a25..9c13e4b7 100644 --- a/src/lib/Hydra/Plugin/RunCommand.pm +++ b/src/lib/Hydra/Plugin/RunCommand.pm @@ -163,8 +163,7 @@ sub buildFinished { $runlog->started(); - my $filename = Hydra::Helper::Nix::constructRunCommandLogFilename(sha1_hex($command), $build->get_column('id')); - my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($filename); + my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog->uuid); my $dir = dirname($logPath); my $oldUmask = umask(); diff --git a/src/lib/Hydra/Schema/Result/RunCommandLogs.pm b/src/lib/Hydra/Schema/Result/RunCommandLogs.pm index 54ab7a2f..6dd4d297 100644 --- a/src/lib/Hydra/Schema/Result/RunCommandLogs.pm +++ b/src/lib/Hydra/Schema/Result/RunCommandLogs.pm @@ -175,8 +175,6 @@ __PACKAGE__->belongs_to( use POSIX qw(WEXITSTATUS WIFEXITED WIFSIGNALED WTERMSIG); use UUID4::Tiny qw(create_uuid_string); -use Digest::SHA1 qw(sha1_hex); -use Hydra::Model::DB; =head2 new @@ -366,29 +364,3 @@ 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"; -} diff --git a/src/root/build.tt b/src/root/build.tt index 8a3a921f..61a846bb 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -526,14 +526,14 @@ END;
Started at [% INCLUDE renderDateTime timestamp = runcommandlog.start_time; %]
[% IF runcommandlog.end_time != undef %]
Ran for [% INCLUDE renderDuration duration = runcommandlog.end_time - runcommandlog.start_time %] - [% IF runcommandlog.log_relative_url() %] -  — Logs + [% IF runcommandlog.uuid != undef %] +  — Logs [% END %]
[% ELSE %]
Running for [% INCLUDE renderDuration duration = curTime - runcommandlog.start_time %] - [% IF runcommandlog.log_relative_url() %] -  — Logs + [% IF runcommandlog.uuid != undef %] +  — Logs [% END %]
[% END %]