From 75bb591c03e5ace54f414be0b07538cce6e17a40 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Tue, 18 May 2010 11:37:01 +0000 Subject: [PATCH] Hydra/32: Add option to force evaluation of a certain jobset via web interface (for admins only) --- src/lib/Hydra/Controller/Admin.pm | 18 +++++++++++++++++- src/lib/Hydra/Helper/AddBuilds.pm | 2 +- src/root/project.tt | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Controller/Admin.pm b/src/lib/Hydra/Controller/Admin.pm index dd659da3..ac1a2ce4 100644 --- a/src/lib/Hydra/Controller/Admin.pm +++ b/src/lib/Hydra/Controller/Admin.pm @@ -5,7 +5,7 @@ use warnings; use base 'Catalyst::Controller'; use Hydra::Helper::Nix; use Hydra::Helper::CatalystUtils; - +use Hydra::Helper::AddBuilds; sub admin : Chained('/') PathPart('admin') CaptureArgs(0) { my ($self, $c) = @_; @@ -86,4 +86,20 @@ sub news_delete : Chained('admin') Path('news/delete') Args(1) { $c->res->redirect("/admin/news"); } +sub force_eval : Chained('admin') Path('eval') Args(2) { + my ($self, $c, $projectName, $jobsetName) = @_; + + my $project = $c->model('DB::Projects')->find($projectName) + or notFound($c, "Project $projectName doesn't exist."); + + $c->stash->{project} = $project; + $c->stash->{jobset_} = $project->jobsets->search({name => $jobsetName}); + $c->stash->{jobset} = $c->stash->{jobset_}->single + or notFound($c, "Jobset $jobsetName doesn't exist."); + + (my $res, my $stdout, my $stderr) = captureStdoutStderr(60, ("hydra_evaluator.pl", $projectName, $jobsetName)); + + $c->res->redirect("/project/$projectName"); +} + 1; diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 889f6338..4d3dc1e0 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -8,7 +8,7 @@ use IPC::Run; use Hydra::Helper::Nix; our @ISA = qw(Exporter); -our @EXPORT = qw(fetchInput evalJobs checkBuild inputsToArgs); +our @EXPORT = qw(fetchInput evalJobs checkBuild inputsToArgs captureStdoutStderr); sub getStorePathHash { diff --git a/src/root/project.tt b/src/root/project.tt index 3237c25b..8f17852f 100644 --- a/src/root/project.tt +++ b/src/root/project.tt @@ -35,6 +35,7 @@ Description Last evaluated Success + [% IF c.check_user_roles('admin') %]Options[% END%] @@ -76,6 +77,9 @@
[% j.get_column('nrsucceeded') %]/[% j.get_column('nrtotal') %]
+ [% IF c.check_user_roles('admin') %] + [ [% INCLUDE maybeLink uri = c.uri_for(c.controller('Admin').action_for('force_eval'), project.name, j.name) content = "Evaluate" confirmmsg = ("Are you sure you want to force evaluation of jobset " _ project.name _ ":" _ j.name _ "?") %] ] + [% END%] [% END %]