diff --git a/src/lib/Hydra/Controller/View.pm b/src/lib/Hydra/Controller/View.pm index b3cbbf6c..ca3dd2f0 100644 --- a/src/lib/Hydra/Controller/View.pm +++ b/src/lib/Hydra/Controller/View.pm @@ -192,16 +192,21 @@ sub result : Chained('view') PathPart('') { [$c->stash->{project}->name, $release->name])); } - # Provide a redirect to the specified job of this view result. - # !!! This isn't uniquely defined if there are multiple jobs with - # the same name (e.g. builds for different platforms). However, - # this mechanism is primarily to allow linking to resources of - # which there is only one build, such as the manual of the latest - # view result. + # Provide a redirect to the specified job of this view result + # through `http://.../view/$project/$viewName/$viewResult/$jobName'. + # Optionally, you can append `-$system' to the $jobName to get a + # build for a specific platform. elsif (scalar @args != 0) { my $jobName = shift @args; - (my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$result->{jobs}}; - notFound($c, "View doesn't have a job named `$jobName'") + my $system; + if ($jobName =~ /^($jobNameRE)-($systemRE)$/) { + $jobName = $1; + $system = $2; + } + (my $build, my @others) = + grep { $_->{job}->job eq $jobName && (!defined $system || ($_->{build} && $_->{build}->system eq $system)) } + @{$result->{jobs}}; + notFound($c, "View doesn't have a job named ‘$jobName’" . ($system ? " for ‘$system’" : "") . ".") unless defined $build; error($c, "Job `$jobName' isn't unique.") if @others; return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'), diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index f838812c..e758d72c 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -11,7 +11,7 @@ our @EXPORT = qw( error notFound requireLogin requireProjectOwner requireAdmin requirePost trim - $pathCompRE $relPathRE $relNameRE $jobNameRE + $pathCompRE $relPathRE $relNameRE $jobNameRE $systemRE ); @@ -174,6 +174,7 @@ Readonly::Scalar our $relPathRE => "(?:$pathCompRE(?:/$pathCompRE)*)"; Readonly::Scalar our $relNameRE => "(?:[A-Za-z0-9-][A-Za-z0-9-\.]*)"; Readonly::Scalar our $attrNameRE => "(?:[A-Za-z_][A-Za-z0-9_]*)"; Readonly::Scalar our $jobNameRE => "(?:$attrNameRE(?:\\.$attrNameRE)*)"; +Readonly::Scalar our $systemRE => "(?:[a-z0-9_]+-[a-z0-9_]+)"; 1; diff --git a/src/root/view-result.tt b/src/root/view-result.tt index 08a24c99..413aa771 100644 --- a/src/root/view-result.tt +++ b/src/root/view-result.tt @@ -27,7 +27,7 @@ [% IF j.build.resultInfo.buildstatus == 0 %] [% IF j.build.buildproducts %] - [% INCLUDE renderProductList build=j.build latestRoot=['/view' project.name view.name 'latest' j.job.job] %] + [% INCLUDE renderProductList build=j.build latestRoot=['/view' project.name view.name 'latest' "${j.job.job}-${j.build.system}"] %] [% ELSE %]
Succeeded.
[% END %]