BuildForge Help

Example: Enabling E-mail Notification

Adaptor templates can be configured to send e-mail notification to users who cause a change in the external application. The following example shows how to set up two types of notification:

The following procedures reference elements in the ClearCaseByDate template. Any adaptor template can use their elements to enable notification.

Notify all users who checked in files for the current build

You can use the <adduser> command to dynamically build the group of users who checked in code for the build, then use the <notify> command to send notifications to that group.

The ClearCaseByDate template queries ClearCase for a view all changes between two timestamps. The default timestamps are for the current adaptor run and the last adaptor run. In practical terms that translates to a list of all changes since the last build that are checked in for the current build.

Assumption: all user names in the view are known to the SMTP server you use for notification by that name. That means ClearCase user names need to align with e-mail user names.

To enable this notification:

  1. Open the ClearCaseByDate adaptor template in an XML editor.
  2. Find and edit the <adduser> to create a group of users, as follows:
    <adduser group="MyChangers" user="$4">
    
    The positional parameter $4 refers to the user name field that is shown in the ClearCase view generated by the ClearCaseByDate template.
  3. Set up notification to send e-mail to this group. The following setup sends e-mail both when the project fails and when the project succeeds. In some environments you may prefer to notify only if the build fails.
    <!-- Set some notifications for when the build completes -->
    		<onproject result="fail">
    			<notify group="MyChangers" subject="Build $BF_TAG ($CurDate) Failed." message="${Changing}${Changes}"/>
    		</onproject>
    		<onproject result="pass">
    			<notify group="MyChangers" subject="Build $BF_TAG ($CurDate) Passed." message="${Changing}${Changes}"/>
    		</onproject>
  4. Save the adaptor template.

When the adaptor runs, the MyChangers group is built from the user names in the view. E-mail notification is sent to that group when the build project completes.

Notify all users who belong to a Build Forge access group

In this example you want to notify all members of a Build Forge access group. The ClearCaseByDate adaptor template is used for the example. Assumption: all user names in Build Forge correspond to e-mail user names in the SMTP server.

  1. Open the ClearCaseByDate adaptor template in an XML editor.
  2. Find and edit the <adduser> to create a group of users from a Build Forge access group, as follows:
    <adduser group="Developer_Access_Group" user="Developer">
  3. Set up notification to send e-mail to this group. The following setup sends e-mail both when the project fails and when the project succeeds. In some environments you may prefer to notify only if the build fails.
    <!-- Set some notifications for when the build completes -->
    <<<<<<< .mine
    		<onproject result="fail">
    			<notify group="Developer_Access_Group" subject="Build $BF_TAG ($CurDate) Failed." message="${Changing}${Changes}"/>
    		</onproject>
    		<onproject result="pass">
    			<notify group="Developer_Access_Group" subject="Build $BF_TAG ($CurDate) Passed." message="${Changing}${Changes}"/>
    		</onproject>
  4. Save the adaptor template.

When the adaptor runs, the Developer_Access_Group group is built from the user names that belong to the Developers access group. E-mail notification is sent to that group when the build project completes.