I'm attempting to create a custom Notificator
plugin for TeamCity which will send a message to my team's Slack instance when one of our builds fail.
We're able to get it running, and it sends messages as expected. The issue arises when we try to query the SRunningBuild
passed into our notifyBuildFailed
method implementation for a list of failure reasons. When we don't attempt this, the failure message is displayed as expected. When we attempt to pull a list of failure reasons, the message is not displayed, and as far as we can tell, no Exceptions are being raised into the logs.
This is an excerpt from our code:
public void notifyBuildFailed(@NotNull SRunningBuild build, @NotNull Set<SUser> users) {
String concatenatedFailureReasons =
getConcatenatedFailureReasons(build.getFailureReasons());
sendNotification("Build failed for the following reasons:\n" +
concatenatedFailureReasons, users);
}
private String getConcatenatedFailureReasons(List<BuildProblemData> reasons) {
String concatenatedFailureReasons = "";
for (BuildProblemData buildProblemData : reasons) {
concatenatedFailureReasons += buildProblemData.getDescription();
}
return concatenatedFailureReasons;
}
As far as I can tell, the failure is actually happening when calling build.getFailureReasons()
since when I made the getConcatenatedFailureReasons
method simply return an empty string, it still failed to display the message properly.
It's hard to actually debug this issue due to what I assume is the nature of TeamCity plugin development. If anyone has a good way to step through TeamCity plugin code, I'd love to hear about that.