Dashboard > CruiseControl.NET > ... > Task Blocks > Email Publisher
Email Publisher Log In | Sign Up   View a printable version of the current page.  
CruiseControl.NET documentation for latest CI builds
Added by Owen Rogers , last edited by Craig Sutherland on Jun 25, 2009  (view change)

The email publisher can be used to send email to any number of users. It is common to include one user who gets an email for every build and then also send email to every developer who checked code in for this build.

People tend to prefer to use CCTray rather than email for instant notification these days.

Make sure that all of the [Merge Publisher]s, along with the Xml Log Publisher task are done before the <email> publisher, or else you won't be able to include output from the build in the email.
A common mistake is to put the email task in the <tasks> section instead of the <publishers> section.
If an error occurs in the <tasks> section, the remaining tasks in that section are skipped, and CC.Net goes right to the <publishers> section.
So if you put the <email> tasks in the <tasks> section, you'll never get any failure messages.
<email from="buildmaster@mycompany.com" mailhost="smtp.mycompany.com" mailport="25" includeDetails="TRUE"
           mailhostUsername="smtpuser" mailhostPassword="smtppassword" useSSL="FALSE">

    <users>
        <user name="BuildGuru" group="buildmaster" address="buildguru@mycompany.com"/>
        <user name="JoeDeveloper" group="developers" address="joedeveloper@thoughtworks.com"/>
    </users>

    <groups>
        <group name="developers">
           <notifications>
	       <notificationType>Failed</notificationType>
	       <notificationType>Fixed</notificationType>
	   </notifications>
        </group>
        <group name="buildmaster" >
           <notifications>
	       <notificationType>Always</notificationType>
           </notifications>
        </group>
    </groups>

    <converters>
       <regexConverter find="$" replace="@TheCompany.com" />
    </converters>

    <modifierNotificationTypes>
       <NotificationType>Failed</NotificationType>
       <NotificationType>Fixed</NotificationType>
    </modifierNotificationTypes>

    <subjectSettings>
       <subject buildResult="StillBroken" value="Build is still broken for {CCNetProject}" />
    </subjectSettings>

    <xslFiles>
       <file>xsl\header.xsl</file>
       <file>xsl\compile.xsl</file>
       <file>xsl\unittests.xsl</file>
       <file>xsl\modifications.xsl</file>
    </xslFiles>

    <attachments>
        <file>C:\Data\AFile.txt</file>
        <file>Relative.txt</file>
    </attachments>
</email>

Configuration Elements:

The authentication elements, mailhostUsername and mailhostPassword, are available starting in CCNet 1.2.
Node Description Type Required Default Version
mailhost The SMTP server that CruiseControl.NET will connect to to send email. string true n/a  
mailport The SMTP server port number (from SVN revision 3462). int false 25  
mailhostUsername The user name to provide to the SMTP server. string false ""  
mailhostPassword The password to provide to the SMTP server. string false ""  
useSSL Use SSL for sending the mail
boolean
false
false
 
from The email address that email will be marked as coming from. string true n/a  
modifierNotificationTypes A set of <NotificationType> elements, specifying build states for which CruiseControl.Net should send an email to the comitters of the build complex false Always  
includeDetails Whether to send a full report or not. If not, just sends a simple status message with a link to the build report boolean false false  
users A set of <user> elements that define who to send emails to. complex true n/a  
groups A set of <group> elements that identify which the notification policy for a set of users. complex true n/a  
converters A set of elements containing rules for creating email adresses based on the modifiers name.
The converters will be used when the name of the modifier is not set in the users section.
complex false n/a  
subjectPrefix
A string that will be the first string of the subject.
string
false
""  
subjectSettings a set of <subject> elements that define the subject of the email, according to the state of the build (broken, fixed, ...)
complex
false
n/a
 
description If filled in, this will be shown in the buildstage as the process name
string
false
n/a  
xslFiles A list of xsl files that will be used to fill up the message body, if left blank the list will be taken from ccnet.exe.config or ccservice.exe.config
list
false
empty
 
attachments A list of files to attach to the e-mail. If the full path is not specified, then it will be relative to the project working directory. string array No Empty 1.5.0
dynamicValues Any dynamic parameters to be used. See Dynamic Parameters Dynamic values array - see Dynamic Parameters No None 1.5.0
When includedDetails = True, the message body will contain more information. This detailed information is constructed from xsl transformations on the build log.
If the xslFiles section is filled these files will be used, if not defined the xls files are defined in the ccnet.exe.config in the xslFiles section. (see also : Server Application Config File). when adjusting one of these, restart the console/service.
The benefits of defining the xsl files in the email publisher :
° the xsl files are automatically the same for the console as for the service (no more keeping these 2 in sync)
° it is possible to give projects different xsl transformations
The groups node may be empty, but the group section must exist.

For sending mail via gmail :
mailhost="smtp.gmail.com"
mailport="587"
mailhostUsername="xxx.yyy@gmail.com"
mailhostPassword="yourpassword"
useSSL="TRUE"

User Configuration Element:

Node Description Type Required
name The user name of a user. This should match the user name in Source Control. string true
group The group that the user is in. This needs to match the name of one of the <group> elements. string false
address The Internet-style email address of the user (e.g., "joe@example.com"). string true

Users do not need to belong to a group. If they are not in a group then they may still receive emails when they have committed changes that are part of the current build, depending on the setting of "modifierNotificationTypes" and the state of the build.

See the section on the <converters> setting for manipulations that can be done to transform a user name to an address if the address is not specified.

It is essential that the value of the name attribute matches the name for the user in the sourcecontrol system. This is the only way that CruiseControl.Net can reconcile the user that committed a change with the address to send the email to.

Group Configuration Element:

Node Description Type Required
name The name of the group, which corresponds to the "group" values used in the <user> elements. string true
notifications A list of notification types, determining when to send email to this group. The possible notification types are:
  • "Always" - send email when any build occurs
  • "Change" - send email when the status of the build changes (e.g. from 'success' to 'failed').
  • "Failed" - send email when the build fails
  • "Success" - send email when the build succeeds
  • "Fixed" - send mail when the status of the build changes from "Failed" to "Success". (available from version 1.3.0.2966)
  • "Exception" - send a mail when the build has state Exception, (e.g. error during getting the modifications)
group true
The ability to configure notifications for successful builds is available starting in CCNet 1.3.

Converters Configuration Element:

The <converters> configuration specifies rules for transforming user names (from <user> elements) to email addresses in cases where the <user> element does not specify an address. The converters are ignored when the <user> element specifies an address.

The converter rules are applied in the order in which they are specified. The first rule transforms a source control userid into a result. Each subsequent rule transforms the result of the previous rule into a new result. The last rule transforms the previous result into an email address. In the simplest case - a single rule - the rule transforms a source control userid into an email address.

Regular Expression Converter Element:

The <regexConverter> element matches the username against a regular expression pattern and modifies it according to a specified replacement. The regular expression language is that of Microsoft's .NET System.Text.RegularExpressions.Regex class.

Node Description Type Required
find The pattern to find string yes
replace The value to substitute with string yes

The find attribute contains a regular expression that is matched against the source control userid. The replace attribute contains a replacement expression that is used to modify the address.

Example : Appending "@TheCompany.com" to the username

This will transform the source control userid "js" into "js@TheCompany.com"

<converters>
    <regexConverter find="$" replace="@TheCompany.com" />
</converters>

Ldap Converter Element

The <ldapConverter> element looks up the email address via LDAP. (available from 1.4.1.3843)

Node Description Type Required Default
domainName the domain holding the LDAP service
string yes empty
ldapQueryField a LDAP query field, used for matching the source control user name 
against a field from the LDAP service
string no MailNickName
ldapLogOnUser
username for loggin on to the LDAP server
string
no
empty
ldapLogOnPassword password for the user logging on the LDAP server string
no
empty
Example

This will search the LDAP for source control userid "js" , using default settings.

<converters>
    <ldapConverter domainName="TheCompany" />
</converters>

This will search the LDAP for source control userid "js" , specifying a user for querying the LDAP.

<converters>
    <ldapConverter domainName="TheCompany" ldapLogOnUser="LdapQuery"  ldapLogOnPassword="LdapQueryPW" />
</converters>

ModifierNotificationTypes Configuration Element:

The <modifierNotificationTypes> configuration specifies the build states for which CruiseControl.Net should send email to the users who contributed changes.

The values of NotificationType are:

Name Condition
Always Send email when any build occurs.
Change Send email when the status of the build changes (e.g., from "Success" to "Failed").
Failed Send email when the build fails.
Success Send email when the build succeeds.
Fixed Send mail when the status of the build changes from "Failed" to "Success".

Users who contribute modifications to a failed build are "sticky". As long as the builds continue to fail, CruiseControl.Net remembers each user who contributed a change to any of the builds. When a build finally succeeds, this list of "failure modifiers" is cleared.

SubjectSettings Configuration Element

This element  allows to set specific subject messages according to the state of the build. When a certain state is not specified, a default will be entered.

Node Description Type Required
buildresult A build result state, see below for the possible values
string true
value The value of the subject line, the text to be used for the subject. This may contain variables, see below.
string true

Buildresult states : 

Name Description
Success The build is yet again successfull.
Broken The build is now broken, it was successfull last time.
StillBroken The build is broken, it was also broken last time.
Fixed The build is ok now, it was broken/exceptioned last time
Exception An error occured during GetModifications, mostly a network / sourcecontrol problem

It is also possible to use variables in this section, these variables are the integration properties :

Label Description Example Version
CCNetBuildCondition The condition used to trigger the build, indicating if the build was triggered by new modifications or if it was forced. Legal values are: "IfModificationExists" or "ForceBuild" ForceBuild  
CCNetIntegrationStatus The status of the current integration. Could be Success, Failure, Exception or Unknown Success  
CCNetLabel The label used to identify the CCNet build. This label is generated by the CCNet labeller. 1.0.2.120  
CCNetLastIntegrationStatus The status of the previous integration. Could be Success, Failure, Exception or Unknown Success  
CCNetProject The name of the CCNet project that is being integrated. MyProject  
CCNetBuildDate The date of the build (in yyyy-MM-dd format) 2005-08-10  
CCNetBuildTime The time of the start of the build (in HH:mm:ss format) 08:45:12  
CCNetArtifactDirectory The project artifact directory (as an absolute path) c:\program files\CruiseControl.NET\Server\MyProject\Artifacts  
CCNetWorkingDirectory The project working directory (as an absolute path) c:\program files\CruiseControl.NET\Server\MyProject\WorkingDirectory  
CCNetRequestSource The source of the integration request; this will generally be the name of the trigger that raised the request. IntervalTrigger 1.1.0
CCNetFailureUsers The list of users who have contributed modifications to a sequence of builds that has failed. John, Smith
 
CCNetListenerFile Viewing build progress with Nant and MSBuild c:\Project\Artifact\listener.xml 1.4.0
CCNetProjectUrl The URL where the project is located http://myhost/ccnet/server/  
CCNetNumericLabel Contains the label as an integer if conversion is possible, otherwise zero. 1  
CCNetModifyingUsers
The list of users who have contributed to the current build only
Smith  
CCNetUser The user who forced the build. If security is off, or the build is not forced, then this will not be set. John Doe 1.5.0

This makes it possible to set up subjects like following :

<subjectSettings>
   <subject buildResult="StillBroken" value="Build is still broken for ${CCNetProject}, please check again  />
</subjectSettings>

or

<subjectSettings>
   <subject buildResult="StillBroken" value="Build is still broken for ${CCNetProject}, the fix failed. />
   <subject buildResult="Broken" value="{CCNetProject} broke at ${CCNetBuildDate} ${CCNetBuildTime } , last checkin(s) by ${CCNetFailureUsers}  />
   <subject buildResult="Exception" value="Serious problem for ${CCNetProject}, it is now in Exception! Check status of network / sourcecontrol />
</subjectSettings>

Troubleshooting

You can find further troubleshooting hints on the System.Web.Mail faq site

Powered by a free Atlassian Confluence Open Source Project License granted to ThoughtWorks, Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators