Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed calculation of 'Back to normal' time #225 #228

Merged
merged 3 commits into from
Jan 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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