in commit-status-publisher-server/src/main/java/jetbrains/buildServer/swarm/commitPublisher/SwarmPublisher.java [208:246]
private void publishCommentIfNeeded(BuildPromotion build,
@NotNull BuildRevision revision,
@NotNull final String commentTemplate,
@NotNull Event event) throws PublisherException {
boolean commentsNotificationsEnabled = ((BuildPromotionEx)build).getBooleanInternalParameterOrTrue(SWARM_COMMENTS_NOTIFICATIONS_ENABLED);
boolean commentSelectively = ((BuildPromotionEx)build).getBooleanInternalParameterOrTrue(SwarmConstants.FEATURE_ENABLE_COMMENTS_SELECTIVELY);
if (commentSelectively && !myCommentOnEvents.contains(event)) {
logStatusNotPublished(build, event, "Comments for this event type have been disabled");
return;
}
PostResult result = postForEachReview(build, revision, new ReviewMessagePublisher() {
@Override
public void publishMessage(@NotNull Long reviewId, @NotNull BuildPromotion build, @NotNull String debugBuildInfo) throws PublisherException {
final String fullComment = "TeamCity: " + buildMessage(build) +
"\nConfiguration: " + myBuildType.getExtendedFullName();
// Do not send e-mail notification for non-personal builds, they are excessive:
boolean enableNotification = commentsNotificationsEnabled && build.isPersonal();
mySwarmClient.addCommentToReview(reviewId, fullComment, debugBuildInfo, !enableNotification);
}
private String buildMessage(@NotNull BuildPromotion build) {
if (commentTemplate.contains("%s")) {
return String.format(commentTemplate, getBuildMarkdownLink(build));
}
else {
return commentTemplate + String.format(" ([view](%s))", getUrl(build));
}
}
});
if (!result.isSuccess()) {
logStatusNotPublished(build, event, result.getMessage());
}
}