ResultsSummary result = getResultSummary(event);
BuildState buildState = result.getBuildState();
String committersText = createCommittersText(result);
try {
client.startInteractiveMode();
KarotzActionPublisher actionPublisher = new KarotzActionPublisher(client);
String message = "";
if (buildState.equals(BuildState.FAILED)) {
message = String.format("Bild ist fehlgeschlagen. %s.", committersText);
changeLight(actionPublisher, RED);
playSound(actionPublisher, FAILED_SOUND, 42000);
} else if (buildState.equals(BuildState.SUCCESS)) {
message = String.format("Bild war erfolgreich. %s.", committersText);
changeLight(actionPublisher, GREEN);
playSound(actionPublisher, SUCCESS_SOUND, 24000);
} else if (buildState.equals(BuildState.UNKNOWN)) {
message = String.format("Bild Resultat ist unbekannt. %s.", committersText);
changeLight(actionPublisher, BLUE);
playSound(actionPublisher, UNKNOWN_SOUND, 23000);
}
actionPublisher.performAction(new SpeakAction(message, LANGUAGE));
Thread.sleep(10000); // wait 10 seconds till karotz has surely finished talking.
client.stopInteractiveMode();
} catch (KarotzException e) {
LOGGER.error("There was an error with Karotz.", e);
} catch (InterruptedException e) {