Source:
private String createBuildsStats(MemoryImprint memoryImprint, TaskListener listener, Map<String, String> parameters) { StringBuilder str = new StringBuilder(""); final String rootUrl = hudson.getRootUrl(); String unsuccessfulMessage = null; Entry[] entries = memoryImprint.getEntries(); if (entries.length > 0) { str.append("\n"); for (Entry entry : entries) { AbstractBuild build = entry.getBuild(); if (build != null) { GerritTrigger trigger = GerritTrigger.getTrigger(build.getProject()); Result res = build.getResult(); String customMessage = null; str.append("\n\n"); if (trigger.getCustomUrl() == null || trigger.getCustomUrl().isEmpty()) { str.append(rootUrl).append(entry.getBuild().getUrl()); } else { str.append(expandParameters(trigger.getCustomUrl(), build, listener, parameters)); } str.append(MESSAGE_DELIMITER); if (res == Result.SUCCESS) { customMessage = trigger.getBuildSuccessfulMessage(); } else if (res == Result.FAILURE || res == Result.ABORTED) { customMessage = trigger.getBuildFailureMessage(); } else if (res == Result.UNSTABLE) { customMessage = trigger.getBuildUnstableMessage(); } else { customMessage = trigger.getBuildFailureMessage(); } if (customMessage == null || customMessage.equals("")) { str.append(res.toString()); } else { str.append(customMessage); } if (res != Result.SUCCESS) { unsuccessfulMessage = entry.getUnsuccessfulMessage(); if (null != unsuccessfulMessage && !unsuccessfulMessage.isEmpty()) { logger.trace("Using unsuccessful message from file."); str.append(" <<<\n"); str.append(unsuccessfulMessage.trim()); str.append("\n>>> "); } } } } } else { logger.error("I got a request to create build statistics, but no entries where found!"); } return str.toString(); }

Target:
private String createBuildsStats(MemoryImprint memoryImprint, TaskListener listener, Map<String, String> parameters) { StringBuilder str = new StringBuilder(""); final String rootUrl = hudson.getRootUrl(); String unsuccessfulMessage = null; Entry[] entries = memoryImprint.getEntries(); if (entries.length > 0) { for (Entry entry : entries) { AbstractBuild build = entry.getBuild(); if (build != null) { GerritTrigger trigger = GerritTrigger.getTrigger(build.getProject()); Result res = build.getResult(); String customMessage = null; str.append("\n\n"); if (trigger.getCustomUrl() == null || trigger.getCustomUrl().isEmpty()) { str.append(rootUrl).append(entry.getBuild().getUrl()); } else { str.append(expandParameters(trigger.getCustomUrl(), build, listener, parameters)); } str.append(MESSAGE_DELIMITER); if (res == Result.SUCCESS) { customMessage = trigger.getBuildSuccessfulMessage(); } else if (res == Result.FAILURE || res == Result.ABORTED) { customMessage = trigger.getBuildFailureMessage(); } else if (res == Result.UNSTABLE) { customMessage = trigger.getBuildUnstableMessage(); } else { customMessage = trigger.getBuildFailureMessage(); } if (customMessage == null || customMessage.equals("")) { str.append(res.toString()); } else { str.append(customMessage); } if (res.isWorseThan(Result.SUCCESS)) { unsuccessfulMessage = entry.getUnsuccessfulMessage(); if (null != unsuccessfulMessage && !unsuccessfulMessage.isEmpty()) { logger.trace("Using unsuccessful message from file."); str.append(" <<<\n"); str.append(unsuccessfulMessage.trim()); str.append("\n>>>"); } } } } } else { logger.error("I got a request to create build statistics, but no entries where found!"); } return str.toString(); }