This Question is Answered

1 "correct" answer available (4 pts) 1 "helpful" answer available (2 pts)
11 Replies Last post: Dec 22, 2011 10:09 PM by Alex Yeisley  
Alex Yeisley Newbie 23 posts since
Dec 10, 2011
Currently Being Moderated

Dec 19, 2011 11:10 PM

Notifications when VCS Changes are detected

I am attempting to send a notification (specifically an email) when changes are detected on a VCS root.  I am able to successfully know when there is a change on the VCS root by extending BuildServerAdapter and overriding the changeAdded method.  Here is my question: Is there a way to access the notifications settings TeamCity uses and supply my own template file?  I was thinking something along the lines of a SendEmail method where I pass in a template file and a list of users to send it to.  Then TeamCity would use the Email Notifier settings to send an email based off the supplied template to the listed users.

 

Thanks for the help,

~Alex

Pavel Sher JetBrains 2,148 posts since
Mar 6, 2008
Currently Being Moderated
Dec 22, 2011 2:25 PM in response to: Alex Yeisley
Re: Notifications when VCS Changes are detected

Sorry for delay, probably you could use jetbrains.buildServer.notification.MessageSender interface. For example, EmailNotifier implements it.

In general you can obtain all of the message senders from ServerExtensionHolder (available as Spring bean):

Collection<MessageSender> messageSenders = extensionHolder.getExtensions(MessageSender.class);

 

Then you can try to find sender you need, compose message and send it to users. In this case you won't need to duplicate SMTP settings in your plugin.

Pavel Sher JetBrains 2,148 posts since
Mar 6, 2008
Currently Being Moderated
Dec 22, 2011 8:24 PM in response to: Alex Yeisley
Re: Notifications when VCS Changes are detected

Unfortunately there is no id at the moment. So you have to use describe() method. We'll improve this API in the future.

Pavel Sher JetBrains 2,148 posts since
Mar 6, 2008
Currently Being Moderated
Dec 22, 2011 8:47 PM in response to: Alex Yeisley
Re: Notifications when VCS Changes are detected

Well, if you want to send notifications by email only, you can indeed take email notifier from the NotificatorRegistry by its id, and then work with it through MessagesSender interface. The only problem with this approach is that email notifier is a plugin and can be removed from the system (manually for example). From the other hand, probability of this is very low.

Pavel Sher JetBrains 2,148 posts since
Mar 6, 2008
Currently Being Moderated
Dec 22, 2011 9:56 PM in response to: Alex Yeisley
Re: Notifications when VCS Changes are detected

If none of the extensions implements MessagesSender interface, you'll receive empty list.

More Like This

  • Retrieving data ...