Skip to content

Commit

Permalink
Merge pull request #228 from gricey432/master
Browse files Browse the repository at this point in the history
Changed calculation of 'Back to normal' time #225
  • Loading branch information
samrocketman authored Jan 15, 2017
2 parents 8b96c38 + b55674d commit d210f6d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/jenkins/plugins/slack/ActiveNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,17 @@ public MessageBuilder appendCustomMessage() {
}

private String createBackToNormalDurationString(){
// This status code guarantees that the previous build fails and has been successful before
// The back to normal time is the time since the build first broke
Run previousSuccessfulBuild = build.getPreviousSuccessfulBuild();
long previousSuccessStartTime = previousSuccessfulBuild.getStartTimeInMillis();
long previousSuccessDuration = previousSuccessfulBuild.getDuration();
long previousSuccessEndTime = previousSuccessStartTime + previousSuccessDuration;
Run initialFailureAfterPreviousSuccessfulBuild = previousSuccessfulBuild.getNextBuild();
long initialFailureStartTime = initialFailureAfterPreviousSuccessfulBuild.getStartTimeInMillis();
long initialFailureDuration = initialFailureAfterPreviousSuccessfulBuild.getDuration();
long initialFailureEndTime = initialFailureStartTime + initialFailureDuration;
long buildStartTime = build.getStartTimeInMillis();
long buildDuration = build.getDuration();
long buildEndTime = buildStartTime + buildDuration;
long backToNormalDuration = buildEndTime - previousSuccessEndTime;
long backToNormalDuration = buildEndTime - initialFailureEndTime;
return Util.getTimeSpanString(backToNormalDuration);
}

Expand Down

0 comments on commit d210f6d

Please sign in to comment.