tcPrettyEmail update for TeamCity 6.5.x

Posted on Updated on

A recent comment from Julien pointed out that tcPrettyEmail messages with Test results are not printing corerctly.

It turns out that the TestBean in the TeamCity API was removed, and I was using that to glean the test detail.  In version 0.8.24.121, I’ve worked around that by building my own bean and passing that to the template engine.

WARNING: This release is only compatible with TeamCity 6.5 and later. For Teamcity 6.0 and earlier, please use the earlier versions.

Screenshot: http://tcplugins.sourceforge.net/screenshot/tcPrettyEmail
Download: http://tcplugins.sourceforge.net/files/tcPrettyEmail
Documentation: http://sourceforge.net/apps/trac/tcplugins/wiki/TcPrettyEmail

If you find a bug or have feature request, please post a comment below or on the tcPrettyEmail bugs page.

Advertisements

23 thoughts on “tcPrettyEmail update for TeamCity 6.5.x

    Ingo said:
    November 2, 2011 at 11:54

    Hello Wolf,

    I’m using TC Version 6.5.2 (build 17935). With the build-in e-mail notifications everything runs fine. Now I want to use your plugin “tcPrettyEmail”, the version is 0.8.24.121. The plugin is installed correctly according to TC’s “Administration -> Server Configuration -> External plugins” list.

    I added the following XML-Code to main-config.xml (and modified the settings for my SMTP-server):

    The problem is, that I don’t get an E-Mail. Maybe there’s a bug in your plugin.

    By the way, does your plugin use the rules of TC for e-mail notification?

    Regards,
    Ingo

    Ingo said:
    November 2, 2011 at 11:57

    UPDATE:
    since XML-tags don’t work, here are the setting without the ‘pretty-mail’ and ‘smtp’-tags:

    host=”mail.company.com” port=”25″ username=”mySmtpUsername” password=”mySmtpPassword” from-address=”friendly.name@company.com” from-name=”Friendly Name”

    netwolfuk responded:
    November 2, 2011 at 20:52

    Hi Ingo.
    The tcPrettyEmailer has its own rules in the “My Settings & Tools” page. If you go to “My Settings & Tools” in TeamCity you should see a section for “Pretty Email Notifier”. You need to set your notification settings in there for the tcPrettyEmailer plugin.
    You should see some logging appear in the teamcity-server.log file on your teamcity server when the plugin sends email.

    Devender said:
    December 30, 2011 at 13:07

    Hi,

    I’m trying to add PrettyEmail plugin to my Teamcity setup but not receiving any emails after a successful build. Already added rules to Pretty Email Notifier in My Settings. On looking server log, I found following error –

    jetbrains.buildServer.SERVER – PrettyEmailNotificator :: Could not assemble the BuildSuccessful prettyemail for bt2 See DEBUG output and/or STDOUT for Stacktrace
    org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource ’email-BuildSuccessful.vm’
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:458)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:341)
    at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:831)
    at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:813)
    at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:470)
    at prettyemailer.teamcity.PrettyEmailMimeMessageHelper.generateEmail(PrettyEmailMimeMessageHelper.java:45)
    at prettyemailer.teamcity.PrettyEmailNotificator.doNotifications(PrettyEmailNotificator.java:220)
    at prettyemailer.teamcity.PrettyEmailNotificator.notifyBuildSuccessful(PrettyEmailNotificator.java:116)
    at jetbrains.buildServer.notification.impl.UserRulesAwareNotificationListener$NotificatorEventAdapter.buildSuccessful(UserRulesAwareNotificationListener.java:135)
    at jetbrains.buildServer.notification.impl.UserRulesAwareNotificationListener.buildSuccessful(UserRulesAwareNotificationListener.java:27)
    at jetbrains.buildServer.notification.NotificationProcessor$3.call(NotificationProcessor.java)
    at jetbrains.buildServer.notification.NotificationProcessor$16.run(NotificationProcessor.java:7)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    Could you please suggest how can this error be resolved?

    Thanks,
    Devender

      netwolfuk responded:
      December 30, 2011 at 13:15

      Hi Deveneder.

      It appears your teamcity is not finding the velocity templates.
      Which TeamCity version are you running?
      Which TeamCity install type are you using (Windows, WAR FIle, Unix, etc).
      What OS are you using?

        Devender said:
        December 31, 2011 at 16:21

        Hi,

        I’m using TeamCity Professional 6.5.6. It’s been installed on windows server 2008. Please suggest where I can find these templates or/and which additional configuration I need to perform to make it working.

        Thanks for your response!

        Devender

    netwolfuk responded:
    January 3, 2012 at 22:51

    Hi Devender.
    I have prepared a zip file containing just the templates and images.
    You can download it from here: http://sourceforge.net/projects/tcplugins/files/tcPrettyEmail_plugin/templates/tcPrettyEmailPlugin-0.8.26.123-templates.zip/download

    Unzip that on your server. Then set the templates and/or images location in the config file as per the documentation here: http://sourceforge.net/apps/trac/tcplugins/wiki/TcPrettyEmail

      Devender said:
      January 4, 2012 at 04:55

      Hi,

      Thanks for sending templates and images! I got it working yesterday before receiving your response. I had to do following steps to make it work –

      1. From the folder- \.BuildServer\plugins\.unpacked\tcPrettyEmailPlugin-0.8.24.121\server, I extracted tcPrettyEmail-0.8.24.121-jar-with-dependencies.jar using WinRAR. Then from folder buildServerResources, got img and templates folders.

      2. Copied img and templates folders to my Teamcity folder in C:\

      3. Updated path of img and templates in main-config.xml

      4. Restarted Teamcity service.

      Then i received a very pretty email about my build status :). It’s very nice looking and provides very useful contents.

      Many thanks to you for providing this plugin and your help to make it work !!

      Regards,
      Devender

        netwolfuk responded:
        January 6, 2012 at 11:01

        Well done. And thanks for your kind feedback.

    Devender said:
    April 16, 2012 at 11:31

    Hello,

    I’m using PrettyEmail in Teamcity for last few months and it’s working very well. Recently, I changed my sending email address to a gmail account and since then PrettyEmail is failing to deliver build email and logging following error –

    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. y3sm7886621pbh.59

    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1829)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1368)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:886)
    at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:403)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:342)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:338)
    at prettyemailer.teamcity.PrettyEmailNotificator.doNotifications(PrettyEmailNotificator.java:231)
    at prettyemailer.teamcity.PrettyEmailNotificator.notifyBuildSuccessful(PrettyEmailNotificator.java:116)
    at jetbrains.buildServer.notification.impl.UserRulesAwareNotificationListener

    I tried to add – securitymode=”STARTTLS” in email settings but not lucky to get the problem solved. Could you please suggest what changes are required to make it work using a Gmail account.

    Thanks,

    Devender

      netwolfuk responded:
      April 17, 2012 at 11:02

      Hi Devender.

      I’ve released a new version that has a new setting to enable STARTTLS support. You can download it from the tcPrettyEmail download page.

      I’ve updated the docs.

      For the username use your gmail account (without the @gmail.com suffix).
      The password is obviously your gmail password.
      The port is 587. The smtp server is smtp.gmail.com.
      Don’t forget to enable TLS with starttls-enabled=”true”.

    Oleg said:
    October 4, 2012 at 06:18

    Hi,

    I’v trying to run tcPrettyMail on TeamCity 7.1.1 without success 😦 Does version 0.8.24.121 compatible with 7.1.1?

      netwolfuk responded:
      October 6, 2012 at 10:22

      I just tested it on 7.1.0 and 7.1.1 and it works for me. What problems are you seeing?
      Have a look for WARN messages in teamcity-server.log and catalina.out in the TeamCity logs directory.

    Oleg said:
    October 8, 2012 at 07:06

    I wonder but I see nothing specifc in logs 😦 Here is excerpt from main-config.xml:


    (just copy-pasted from working TeamCity Professional 6.5 (build 17795) with lite changes)

    User has further notification rules:
    – Build is successful
    – Tests are muted or unmuted
    – Build fails
    – Build fails to start
    – Build is probably hanging
    – The first build error occurs
    – Investigation is updated

    Regular email notifier works fine.

    To be honest I have no idea what is wrong 😦

    P.S.: How can fire email sending or send test email by hand?
    My dist is ‘TeamCity Professional 7.1.1 (build 24074)’

    Thanks,
    Oleg

      Oleg said:
      October 8, 2012 at 07:08

      damn… excerpt is trimed…
      (pretty-email)
      (smtp host=”hostname” port=”25″ starttls-enabled=”false”
      username=”???” password=”???” from-address=”email@hostname”
      from-name=”TeamCity” /)
      (template-path path=”/opt/jetbrains/TeamCity/webapps/ROOT/plugins/tcPrettyEmailer/templates/” /)
      (attachment-path path=”/opt/jetbrains/TeamCity/webapps/ROOT/plugins/tcPrettyEmailer/img/” /)
      (attach-images attach=”true” /)
      (max-tests-to-show value=”5″ /)
      (max-error-lines-to-show value=”50″ /)
      (/pretty-email)

    Mark Jaffe said:
    April 16, 2013 at 18:41

    I am running 0.8.29.125 on TC 6.5.6 and see the issue still. Do I need EXACTLY the 0.8.24.121 release for this fix? Can you also respond to SourceForge issue I raised: http://sourceforge.net/apps/trac/tcplugins/ticket/2

      netwolfuk responded:
      April 16, 2013 at 21:21

      Hi Mark. Any version after 0.8.24.121 should work (unless I have a regression). I was going to look at the bug report last night but didn’t have a tc6.5.6 to test on. Will download it and test. Sorry for the delay.

    pazhani1988 said:
    March 15, 2016 at 06:07

    Hi,

    I would like to have following feature.

    I have a TeamCity Project. That TC Project has multiple build configurations (say 10). All the build configurations are dependent (snapshot dependencies used).

    For the above configuration, I wanted to send a single email notification email. I have to send email if any of the build gets failed and all the build gets success with the summary.

    Please let me know if this is possible.

      netwolfuk responded:
      March 15, 2016 at 10:23

      tcPrettyEmail hooks into the same API calls as the standard TeamCity mailer.
      If you can do what you want in the standard mailer, then it should be possible in tcPrettyEmail.

      Can you try configuring what you want in the standard mailer and let me know whether you can get it working?

        pazhani1988 said:
        March 15, 2016 at 12:43

        The standard mailer also doesn’t have this option!!!

        netwolfuk responded:
        March 15, 2016 at 18:42

        Yes. I suspected that would be the case. Sorry, tcPrettyEmail won’t be able to either.

    Mohit said:
    October 11, 2016 at 17:47

    Hi netwolfuk,

    I have a bit different requirement and I am in doubt if this plugin will help me. Can you please suggest.

    I have to notify users about build failure on teamcity and it should only send emails to users who recently committed code, which caused build failure.

    Thanks,
    Mohit

      netwolfuk responded:
      October 11, 2016 at 18:59

      This plugin send email using the rules defined in teamcity.
      Fortunately, these rules support what you want to do.
      Ask your users to go into My Settings & Tools, click “Edit” next to Pretty Email Notifier, and setup a new rule for “Builds with my changes only” and some failure condition(s).
      All of the notifier support this, not just the Pretty Emailer, but of course I would recommend that as the best 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s