Skip to content
Permalink
Browse files
[FIXED JENKINS-9442] don't send 'oh now you've broken xyz' notificati…
…on for builds which have improved from FAILURE to UNSTABLE
  • Loading branch information
kutzi committed Apr 19, 2011
1 parent 074db79 commit f10b48108f0792fc6e5d90523a8f2f708ae12413
@@ -11,6 +11,7 @@
import hudson.plugins.im.build_notify.DefaultBuildToChatNotifier;
import hudson.plugins.im.tools.BuildHelper;
import hudson.plugins.im.tools.ExceptionHelper;
import hudson.plugins.im.tools.BuildHelper.ExtResult;
import hudson.scm.ChangeLogSet;
import hudson.scm.ChangeLogSet.Entry;
import hudson.tasks.BuildStep;
@@ -275,7 +276,7 @@ public boolean perform(final AbstractBuild<?,?> build, final Launcher launcher,
notifyChats(build, buildListener);
}

if (BuildHelper.isStillFailureOrUnstable(build)) {
if (BuildHelper.isStillFailureOrUnstable(build) || BuildHelper.getExtendedResult(build) == ExtResult.NOW_UNSTABLE) {
if (this.notifySuspects) {
log(buildListener, "Notifying suspects");
final String message = getBuildToChatNotifier().suspectMessage(this, build, buildListener, false);
@@ -16,7 +16,12 @@
* @author kutzi
*/
public static enum ExtResult {
FIXED, SUCCESS, STILL_UNSTABLE("STILL UNSTABLE"), UNSTABLE,
FIXED, SUCCESS,
/**
* Marks a build which was previously a failure and is now 'only' unstable.
*/
NOW_UNSTABLE("NOW UNSTABLE"),
STILL_UNSTABLE("STILL UNSTABLE"), UNSTABLE,
STILL_FAILING("STILL FAILING"), FAILURE,
ABORTED, NOT_BUILT("NOT BUILT");

@@ -135,8 +140,15 @@ public static ExtResult getExtendedResult(AbstractBuild<?, ?> build) {

AbstractBuild<?, ?> previousBuild = getPreviousNonAbortedBuild(build);
if (result == Result.UNSTABLE) {
if (previousBuild != null && previousBuild.getResult() == Result.UNSTABLE) {
if (previousBuild == null) {
return ExtResult.UNSTABLE;
}


if (previousBuild.getResult() == Result.UNSTABLE) {
return ExtResult.STILL_UNSTABLE;
} else if (previousBuild.getResult() == Result.FAILURE) {
return ExtResult.NOW_UNSTABLE;
} else {
return ExtResult.UNSTABLE;
}
@@ -7,6 +7,7 @@
import static org.mockito.Mockito.when;
import hudson.model.FreeStyleBuild;
import hudson.model.Result;
import hudson.plugins.im.tools.BuildHelper.ExtResult;

import org.junit.Test;

@@ -105,5 +106,10 @@ public void testGetResultDescription() throws Exception {
when(build.getResult()).thenReturn(Result.SUCCESS);
// don't mark it as fixed:
assertEquals("SUCCESS", BuildHelper.getResultDescription(build));

// NOW UNSTABLE
when(previousBuild.getResult()).thenReturn(Result.FAILURE);
when(build.getResult()).thenReturn(Result.UNSTABLE);
assertEquals(ExtResult.NOW_UNSTABLE.toString(), BuildHelper.getResultDescription(build));
}
}

0 comments on commit f10b481

Please sign in to comment.