@@ -45,6 +45,7 @@ public class BuildNotifier {
4545
4646 private final Message message ;
4747 private final AbstractBuild build ;
48+ private final BuildStatus status ;
4849 private final Result result ;
4950 private final String baseUrl ;
5051 private final boolean sendIfSuccess ;
@@ -58,6 +59,7 @@ public class BuildNotifier {
5859 public BuildNotifier (Message message , AbstractBuild build , boolean sendIfSuccess ) {
5960 this .message = message ;
6061 this .build = build ;
62+ this .status = BuildStatus .of (build );
6163 this .result = build .getResult ();
6264 this .baseUrl = JenkinsLocationConfiguration .get ().getUrl ();
6365 this .sendIfSuccess = sendIfSuccess ;
@@ -67,7 +69,7 @@ public BuildNotifier(Message message, AbstractBuild build, boolean sendIfSuccess
6769 * Sends the notification through the given message object.
6870 */
6971 public void sendNotification () {
70- if (result . ordinal == 0 ) {
72+ if (status == BuildStatus . SUCCESSFUL ) {
7173 if (sendIfSuccess ) {
7274 sendMessage ();
7375 }
@@ -92,12 +94,12 @@ private void setUrl() {
9294 }
9395
9496 private void setContent () {
95- if (build .getChangeSet ().getItems ().length == 0 ){
97+ if (build .getChangeSet ().getItems ().length == 0 ) {
9698 message .setContent (result .toString ());
9799 } else {
98100 StringBuilder changes = new StringBuilder ();
99101
100- for (Iterator <? extends ChangeLogSet .Entry > i = build .getChangeSet ().iterator (); i .hasNext ();) {
102+ for (Iterator <? extends ChangeLogSet .Entry > i = build .getChangeSet ().iterator (); i .hasNext (); ) {
101103 ChangeLogSet .Entry change = i .next ();
102104 changes .append ("\n " );
103105 changes .append (change .getMsg ());
@@ -111,20 +113,25 @@ private void setContent() {
111113
112114 private void setTitle () {
113115 message .setTitle (String .format (
114- "Build #%d of %s" ,
116+ "%s - Build #%d of %s" ,
117+ status .tag (),
115118 build .getNumber (),
116119 build .getProject ().getName ()
117120 ));
118121 }
119122
120123 private void setPriority () {
121- switch (result . ordinal ) {
122- case 0 : //SUCCESS
123- message .lowPriority ();
124+ switch (status ) {
125+ case FIXED :
126+ message .normalPriority ();
124127 break ;
125- case 2 : //FAILURE
128+ case BROKEN :
129+ case STILL_BROKEN :
126130 message .highPriority ();
127131 break ;
132+ case SUCCESSFUL :
133+ message .lowPriority ();
134+ break ;
128135 }
129136 }
130137
0 commit comments