Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix empty message issues

When there is no config set there was an empty message being sent,
instead make sure the defaults are used.
  • Loading branch information...
commit 333d376c19b2136456f126bf631ff102aa061383 1 parent 2e33605
@marcins authored
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/main/java/jenkins/plugins/hipchat/ActiveNotifier.java
View
9 src/main/java/jenkins/plugins/hipchat/ActiveNotifier.java
@@ -50,11 +50,10 @@ public void started(AbstractBuild build) {
messageParams.put("changes", changes);
messageParams.put("link", MessageBuilder.getOpenLink(notifier, build));
- if (notifier.getMessageTemplateStarted() == null)
+ if (notifier.getMessageTemplateStarted() == null || "".equals(notifier.getMessageTemplateStarted()))
{
- logger.warning("Started message template is not set!");
+ logger.warning("Started message template is not set, using default");
notifier.setMessageTemplateStarted("{{build.project.displayName}} - {{build.displayName}}: Started {{#cause}}{{cause.shortDescription}}{{/cause}} {{#changes}}{{changes}}{{/changes}} {{{link}}}");
- return;
}
notifyStart(build, applyMessageTemplate(notifier.getMessageTemplateStarted(), messageParams));
@@ -78,9 +77,9 @@ public void completed(AbstractBuild r) {
|| (result == Result.SUCCESS && jobProperty.getNotifySuccess())
|| (result == Result.UNSTABLE && jobProperty.getNotifyUnstable())) {
- if (notifier.getMessageTemplateCompleted() == null)
+ if (notifier.getMessageTemplateCompleted() == null || "".equals(notifier.getMessageTemplateCompleted()))
{
- logger.warning("Completed message template is not set!");
+ logger.warning("Completed message template is not set, using default");
notifier.setMessageTemplateCompleted("{{build.project.displayName}} - {{build.displayName}}: {{status}} after {{build.durationString}} {{{link}}}");
}

2 comments on commit 333d376

@phil-schneider

Please use StringUtils.isBlank for checking if a string is .
I would also change the logger from warning to info.
Warning means: do something or it will might lead to a bug.

@marcins
Owner

Thanks for the feedback - the warnings aren't there in the latest commit, but I've changed the way I check for blank strings.

Please sign in to comment.
Something went wrong with that request. Please try again.