From caa0f1a255578dd59c86435787fe96a2d62bf229 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Wed, 14 Jul 2010 07:31:14 +0000 Subject: [PATCH] Hydra: In case of failure, also show changes between last succesful build and the first failed build after this --- src/lib/Hydra/Controller/Build.pm | 1 + src/lib/Hydra/Helper/CatalystUtils.pm | 16 +++++++++++++++- src/root/build.tt | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index a08c7a28..f71462c0 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -22,6 +22,7 @@ sub build : Chained('/') PathPart CaptureArgs(1) { $c->stash->{prevBuild} = getPreviousBuild($c, $c->stash->{build}); $c->stash->{prevSuccessfulBuild} = getPreviousSuccessfulBuild($c, $c->stash->{build}); + $c->stash->{firstBrokenBuild} = getNextBuild($c, $c->stash->{prevSuccessfulBuild}); $c->stash->{mappers} = [$c->model('DB::UriRevMapper')->all]; diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index e258df83..5b156ece 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -7,7 +7,7 @@ use Hydra::Helper::Nix; our @ISA = qw(Exporter); our @EXPORT = qw( - getBuild getPreviousBuild getPreviousSuccessfulBuild getBuildStats joinWithResultInfo getChannelData + getBuild getPreviousBuild getNextBuild getPreviousSuccessfulBuild getBuildStats joinWithResultInfo getChannelData error notFound requireLogin requireProjectOwner requireAdmin requirePost isAdmin isProjectOwner trim @@ -35,6 +35,20 @@ sub getPreviousBuild { return $prevBuild; } +sub getNextBuild { + my ($c, $build) = @_; + (my $nextBuild) = $c->model('DB::Builds')->search( + { finished => 1 + , system => $build->system + , project => $build->project->name + , jobset => $build->jobset->name + , job => $build->job->name + , 'me.id' => { '>' => $build->id } + }, {rows => 1, order_by => "id ASC"}); + + return $nextBuild; +} + sub getPreviousSuccessfulBuild { my ($c, $build) = @_; (my $prevBuild) = joinWithResultInfo($c, $c->model('DB::Builds'))->search( diff --git a/src/root/build.tt b/src/root/build.tt index 7bce159e..5720c790 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -183,6 +183,16 @@ [% INCLUDE renderBuildSteps type="Failed" %] [% END %] + [% IF prevSuccessfulBuild && firstBrokenBuild && firstBrokenBuild.id != build.id %] +

Changes

+

+ Build [% INCLUDE renderFullBuildLink build=firstBrokenBuild %] is the first build failure after the previous successful build of this job. The changes that might have caused the failure are: +

+ [% INCLUDE renderInputDiff build2=prevSuccessfulBuild , build1=firstBrokenBuild %] +
+

+ [% END %] + [% IF build.resultInfo.buildstatus != 0 && prevSuccessfulBuild %]

Changes