Email notification

CVSNT contains a trigger library which is capable of sending notification emails on commit, tag or notify. It allows you to put any contents in the emails, but the output format is fairly simple - it is no substitute for a purpose designed notification program.

Email sending is disabled by default. To configure it for use you must do the following.

Configure the commit support files

The commit support files commit_email, tag_email and notify_email contain the names of the template files to use for commit, tag and notify respectively. Each line in these files is a regular expression followed by a filename. The filename is always relative to the CVSROOT directory and may not be an absolute path for security reasons.

The first matching line for each directory committed is used. If there is no match the DEFAULT line is used.

The name of the template file should also be listed in the checkoutlist file so that it is available for the script to use.

The CVSROOT/users file is used to lookup the username -> email mapping. This file is a list of colon separated username/email pairs. If this file does not exist or the username is not listed the default domain name set in the global configuration is used.

Write the template

The template file is a simple text file listing the exact text of the email to send including headers. The To:, From:, Cc: and Bcc: lines are used by the sending software to determing the addresses to use.

An example commit template is:

From: [email]
To: cvsnt_users@mycompany.com
Subject: Commit to [module]

CVSROOT:     [repository]
Module name: [module]
Changes by:  [email]           [date]
On host:     [hostname]

[begin_directory]
Directory: [directory]

[begin_file]
[change_type] [filename]   [tag]   [old_revision] -> [new_revision]   [bugid]
[end_file]
[end_directory]

Log message:
[message]

A number of replacements are done on the file to format it for final sending. This differs for each file, and is listed below.

Configure the server

There are two ways that CVSNT can send email. The simplest is to set the SMTP Server and default domain in the global configuration (Control Panel in win32, /etc/cvsnt/PServer in Unix) and let the internal SMTP client send the emails.

This will not work in the case where authenticaton is required or the server is not capable of SMTP. In these cases you instead set the Email Command. This command should take a list of 'to' addresses as parameters, and a raw RFC822 email as its standard input.

A suitable configuration for Unix systems is

/usr/sbin/sendmail -i

Similar programs exist for Win32.

Keywords used in template files

The following are the global keywords used in the email template files.

[hostname]

Client hostname, it known

[repository]

Repository name

[commitid] or [sessionid]

Session identifier

[server_hostname]

Local hostname of server

[user]

User who is performing the action

[email]

Email address, as looked up from CVSROOT/users

[date]

Date/time of action

[message]

Message associated with action, if any

[module]

Module associated with action

[begin_directory] .. [end_directory]

Lines between these tags (which must be on their own on the line) are repeated for each directory referenced by the operation.

[begin_file] .. [end_file]

Lines between these tags (which must be on their own on the line) are repeated for each file referenced by the operation. These tags can only exist inside begin/end directory tags.

[directory]

Current directory

[filename]

Curent file

Each type of template also has its own keywords that is uses:

commit emails

[old_revision]

Revision number of previous revision.

[new_revision]

Revision number of new revision.

[tag]

Tag for file.

[change_type]

Code for change made by this commit.. 'M', 'A', etc.

tag emails

[tag_type]

Type of tag operation.

[action]

What is being done with the tag.

[tag]

Tag for file

[revision]

File revision that is being tagged.

notify emails

[bugid]

Bug identifier(s) associated with this notification.

[tag]

Tag name of file

[notify_type]

Notification type