package tools.devnull.jenkins.plugins.buildnotifications;

import hudson.model.AbstractBuild;

/**
 * Enumeration of the possible build status for notification purposes.
 */
public enum BuildStatus {

  BROKEN("Broken"),
  STILL_BROKEN("Still Broken"),
  FIXED("Fixed"),
  SUCCESSFUL("Successful");

  private final String tag;

  BuildStatus(String tag) {
    this.tag = tag;
  }

  public String tag() {
    return this.tag;
  }

  public static BuildStatus of(AbstractBuild build) {
    AbstractBuild previousBuild = build.getPreviousBuild();
    if (build.getResult().ordinal == 0) {
      if (previousBuild != null) {
        return previousBuild.getResult().ordinal == 0 ? SUCCESSFUL : FIXED;
      } else {
        return SUCCESSFUL;
      }
    } else {
      if (previousBuild != null) {
        return previousBuild.getResult().ordinal != 0 ? STILL_BROKEN : BROKEN;
      } else {
        return BROKEN;
      }
    }
  }

}

@@ -86,16 +86,44 @@
 ctBuild;
+%0Aimport hudson.model.Result;
 %0A%0A/**%0A *
@@ -604,17 +604,38 @@
 inal == 
-0
+Result.SUCCESS.ordinal
 ) %7B%0A    
@@ -717,17 +717,38 @@
 inal == 
-0
+Result.SUCCESS.ordinal
  ? SUCCE
@@ -916,9 +916,30 @@
  != 
-0
+Result.SUCCESS.ordinal
  ? S

Allow different types of notifications (#9)