This page last changed on Dec 12, 2008 by williams.

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 Publishers, 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" notification="change"/>
        <group name="buildmaster" notification="always"/>
    </groups>

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

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

</email>

Configuration Elements:

The authentication elements, mailhostUsername and mailhostPassword, are available starting in CCNet 1.2.
Node Description Type Required Default
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
""
When includedDetails = True, the message body will contain more information. This detailed information is constructed from xsl transformations on the build log.
These xls files are defined in the ccnet.exe.config in the xslFiles section. (see also : Server Application Config File). when adjustig this, restart the console/service.
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 false

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
notification Determines 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)
string 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.

Troubleshooting

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

Document generated by Confluence on Dec 13, 2008 00:16