Skip to content

Commit

Permalink
Merge pull request #9 from jglick/no-checkpoint-JENKINS-20867
Browse files Browse the repository at this point in the history
[JENKINS-20867] Do not use checkpoints
  • Loading branch information
jglick committed Dec 5, 2013
2 parents 4f6be2d + a32b1f1 commit 7370b75
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/main/java/hudson/tasks/MailSender.java
Expand Up @@ -124,8 +124,6 @@ public boolean execute(AbstractBuild<?, ?> build, BuildListener listener) throws
e.printStackTrace(listener.error(e.getMessage()));
} catch (UnsupportedEncodingException e) {
e.printStackTrace(listener.error(e.getMessage()));
} finally {
CHECKPOINT.report();
}

return true;
Expand All @@ -137,14 +135,14 @@ public boolean execute(AbstractBuild<?, ?> build, BuildListener listener) throws
* See http://www.nabble.com/Losing-build-state-after-aborts--td24335949.html
*
* <p>
* And since we are consulting the earlier result, we need to wait for the previous build
* to pass the check point.
* And since we are consulting the earlier result, if the previous build is still running, behave as if this were the first build.
*/
private Result findPreviousBuildResult(AbstractBuild<?,?> b) throws InterruptedException {
CHECKPOINT.block();
do {
b=b.getPreviousBuild();
if(b==null) return null;
if (b == null || b.isBuilding()) {
return null;
}
} while((b.getResult()==Result.ABORTED) || (b.getResult()==Result.NOT_BUILT));
return b.getResult();
}
Expand All @@ -158,7 +156,7 @@ protected MimeMessage getMail(AbstractBuild<?, ?> build, BuildListener listener)
if (!dontNotifyEveryUnstableBuild)
return createUnstableMail(build, listener);
Result prev = findPreviousBuildResult(build);
if (prev == Result.SUCCESS)
if (prev == Result.SUCCESS || prev == null)
return createUnstableMail(build, listener);
}

Expand Down Expand Up @@ -436,9 +434,4 @@ protected boolean artifactMatches(String path, AbstractBuild<?, ?> build) {

private static final int MAX_LOG_LINES = Integer.getInteger(MailSender.class.getName()+".maxLogLines",250);


/**
* Sometimes the outcome of the previous build affects the e-mail we send, hence this checkpoint.
*/
private static final CheckPoint CHECKPOINT = new CheckPoint("mail sent");
}

0 comments on commit 7370b75

Please sign in to comment.