Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ work/
.project
.settings/

.idea/*
10 changes: 8 additions & 2 deletions src/main/java/com/flowdock/jenkins/BuildResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public enum BuildResult {
UNSTABLE("was unstable"),
ABORTED("was aborted"),
NOT_BUILT("was not built"),
FIXED("was fixed");
FIXED("was fixed"),
BROKEN("was broken");

private String humanResult;

Expand All @@ -18,8 +19,9 @@ private BuildResult(String displayName) {
}

public static BuildResult fromBuild(AbstractBuild build) {
Result prevResult = build.getPreviousBuild() != null ? build.getPreviousBuild().getResult() : null;

if (build.getResult().equals(Result.SUCCESS)) {
Result prevResult = build.getPreviousBuild() != null ? build.getPreviousBuild().getResult() : null;
if (Result.FAILURE.equals(prevResult) || Result.UNSTABLE.equals(prevResult)) {
return FIXED;
}
Expand All @@ -31,6 +33,10 @@ public static BuildResult fromBuild(AbstractBuild build) {
} else if (build.getResult().equals(Result.NOT_BUILT)) {
return NOT_BUILT;
} else {
if (!(Result.FAILURE.equals(prevResult) || Result.UNSTABLE.equals(prevResult))) {
return BROKEN;
}

return FAILURE;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/flowdock/jenkins/FlowdockNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ public class FlowdockNotifier extends Notifier {
private final boolean notifyUnstable;
private final boolean notifyAborted;
private final boolean notifyNotBuilt;
private final boolean notifyBroken;

// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
@DataBoundConstructor
public FlowdockNotifier(String flowToken, String notificationTags, String chatNotification,
String notifySuccess, String notifyFailure, String notifyFixed, String notifyUnstable,
String notifyAborted, String notifyNotBuilt) {
String notifyAborted, String notifyNotBuilt, String notifyBroken) {
this.flowToken = flowToken;
this.notificationTags = notificationTags;
this.chatNotification = chatNotification != null && chatNotification.equals("true");
Expand All @@ -53,6 +54,7 @@ public FlowdockNotifier(String flowToken, String notificationTags, String chatNo
this.notifyUnstable = notifyUnstable != null && notifyUnstable.equals("true");
this.notifyAborted = notifyAborted != null && notifyAborted.equals("true");
this.notifyNotBuilt = notifyNotBuilt != null && notifyNotBuilt.equals("true");
this.notifyBroken = "true".equals(notifyBroken);

// set notification map
this.notifyMap = new HashMap<BuildResult, Boolean>();
Expand All @@ -62,6 +64,7 @@ public FlowdockNotifier(String flowToken, String notificationTags, String chatNo
this.notifyMap.put(BuildResult.UNSTABLE, this.notifyUnstable);
this.notifyMap.put(BuildResult.ABORTED, this.notifyAborted);
this.notifyMap.put(BuildResult.NOT_BUILT, this.notifyNotBuilt);
this.notifyMap.put(BuildResult.BROKEN, this.notifyBroken);
}

public String getFlowToken() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<f:entry title="Fixed" field="notifyFixed">
<f:checkbox default="true" value="true" />
</f:entry>
<f:entry title="Broken" field="notifyBroken">
<f:checkbox default="true" value="true" />
</f:entry>
<f:entry title="Unstable" field="notifyUnstable">
<f:checkbox value="true" />
</f:entry>
Expand Down