diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 68496a7c..64919f6b 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -39,43 +39,49 @@ sub view_build : Chained('build') PathPart('') Args(0) { } -sub view_nixlog : Chained('build') PathPart('nixlog') Args(1) { - my ($self, $c, $stepnr) = @_; +sub view_nixlog : Chained('build') PathPart('nixlog') { + my ($self, $c, $stepnr, $mode) = @_; my $step = $c->stash->{build}->buildsteps->find({stepnr => $stepnr}); notFound($c, "Build doesn't have a build step $stepnr.") if !defined $step; - $c->stash->{template} = 'log.tt'; $c->stash->{step} = $step; - # !!! should be done in the view (as a TT plugin). - $c->stash->{logtext} = loadLog($c, $step->logfile); + showLog($c, $step->logfile, $mode); } -sub view_log : Chained('build') PathPart('log') Args(0) { - my ($self, $c) = @_; +sub view_log : Chained('build') PathPart('log') { + my ($self, $c, $mode) = @_; error($c, "Build didn't produce a log.") if !defined $c->stash->{build}->resultInfo->logfile; - $c->stash->{template} = 'log.tt'; - - # !!! should be done in the view (as a TT plugin). - $c->stash->{logtext} = loadLog($c, $c->stash->{build}->resultInfo->logfile); + showLog($c, $c->stash->{build}->resultInfo->logfile, $mode); } -sub loadLog { - my ($c, $path) = @_; +sub showLog { + my ($c, $path, $mode) = @_; notFound($c, "Log file $path no longer exists.") unless -f $path; - - # !!! quick hack - my $pipeline = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path") - . " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -" - . " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2"; - return `$pipeline`; + if ($mode eq "") { + # !!! quick hack + my $pipeline = ($path =~ /.bz2$/ ? "cat $path | bzip2 -d" : "cat $path") + . " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -" + . " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2"; + + $c->stash->{template} = 'log.tt'; + $c->stash->{logtext} = `$pipeline`; + } + + elsif ($mode eq "raw") { + $c->serve_static_file($path); + } + + else { + error($c, "Unknown log display mode `$mode'."); + } } diff --git a/src/root/build.tt b/src/root/build.tt index d986421a..486893a7 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -163,6 +163,7 @@ Logfile: Available + (raw) [% END %] @@ -249,7 +250,7 @@ Failed: [% HTML.escape(step.errormsg) %] [% END %] [% IF step.logfile %] - (log) + (log, raw) [% END %] diff --git a/src/root/common.tt b/src/root/common.tt index 6bb8f70c..d2add394 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -33,14 +33,12 @@ [% BLOCK renderFullJobName %] [% INCLUDE renderProjectName %]:[% INCLUDE renderJobsetName %]:[% INCLUDE renderJobName %] - + [% END %] [% BLOCK renderFullJobNameOfBuild %] - [% INCLUDE renderFullJobName project=build.get_column("project") jobset = build.get_column("jobset") job = build.get_column("job") %] - [% END %] diff --git a/src/root/log.tt b/src/root/log.tt index d2e809ff..744ed16f 100644 --- a/src/root/log.tt +++ b/src/root/log.tt @@ -1,6 +1,9 @@ [% WRAPPER layout.tt title="Logfile" %] +[% PROCESS common.tt %] -

Logfile for [% build.project.name %]:[% build.job %] build [% build.id %][%IF step %], step [% step.stepnr %] ([% step.outpath %])[% END %]

+

Logfile for [% INCLUDE renderFullJobNameOfBuild %] build [% build.id %][%IF step %] step [% step.stepnr %][% END %]

+ +

Below is the logfile of the build producing Nix store path [% step.outpath %].

[% logtext -%]