Skip to content

Commit

Permalink
[FIXED JENKINS-9687] log build steps which have changed the build res…
Browse files Browse the repository at this point in the history
…ult to console
  • Loading branch information
kutzi committed May 22, 2011
1 parent 0b01182 commit a3d1388
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -77,6 +77,9 @@
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-9671">issue 9671</a>)
<li class=rfe>
Add a default attribute to repeatableProperty and repeatable jelly tags
<li class=rfe>
Log which build steps have changed the build result to build console.
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-9687">issue 9687</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
21 changes: 20 additions & 1 deletion core/src/main/java/hudson/model/AbstractBuild.java
Expand Up @@ -659,7 +659,26 @@ protected final boolean perform(BuildStep bs, BuildListener listener) throws Int
} catch (AbstractMethodError e) {
mon = BuildStepMonitor.BUILD;
}
return mon.perform(bs, AbstractBuild.this, launcher, listener);
Result oldResult = AbstractBuild.this.getResult();
boolean canContinue = mon.perform(bs, AbstractBuild.this, launcher, listener);
Result newResult = AbstractBuild.this.getResult();
if (newResult != oldResult) {
String buildStepName = getBuildStepName(bs);
listener.getLogger().format("Build step '%s' changed build result to %s%n", buildStepName, newResult);
}
if (!canContinue) {
String buildStepName = getBuildStepName(bs);
listener.getLogger().format("Build step '%s' marked build as failure%n", buildStepName);
}
return canContinue;
}

private String getBuildStepName(BuildStep bs) {
if (bs instanceof Describable<?>) {
return ((Describable<?>) bs).getDescriptor().getDisplayName();
} else {
return bs.getClass().getSimpleName();
}
}

protected final boolean preBuild(BuildListener listener,Map<?,? extends BuildStep> steps) {
Expand Down

0 comments on commit a3d1388

Please sign in to comment.