Skip to content

Commit

Permalink
Emit 'result' and 'status' field when useStatusFormat is enabled.
Browse files Browse the repository at this point in the history
To increase backward compatibility.
  • Loading branch information
mzp committed Jul 13, 2013
1 parent 0b99aa8 commit 40250b1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/codefirst/jenkins/wsnotifier/WsServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,21 @@ static public void send(AbstractBuild build, boolean useStatusFormat){
}

static public void send(AbstractBuild build, String result, boolean useStatusFormat){
String statusName = useStatusFormat ? "status" : "result";
if (result == null){
result = build.getResult().toString();
}
String json = new JSONObject()
JSONObject json = new JSONObject()
.element("project", build.getProject().getName())
.element("number" , new Integer(build.getNumber()))
.element(statusName , result)
.toString();
.element("status", result);

// for backward compatibilty
try{
json.element("result", build.getResult().toString());
}catch(Exception e) {}

for(WebSocketConnection con : connections){
con.send(json);
con.send(json.toString());
}

// it's not necessary to send out a ping immediately or shortly after having send a client message.
Expand Down

0 comments on commit 40250b1

Please sign in to comment.