In this page

Sending a notification email about a new changeset

This automation sends a notification email about the changeset after that has been accepted by the repository:

The email recipients, subject, content and other details can be freely customized. Note that you can also use this approach to integrate external services that accept email as "incoming message" format to your DevOps pipelines.

Configuration

  1. Login to Jira as admin, go to AdministrationSystemAutomation rules.
  2. Click Create rule.
  3. Select the trigger Changeset accepted (from the DevOps category).
  4. Click Save.
  5. Click Add component and select New condition.
  6. Select the condition Advanced compare condition.
    1. Enter {{devops.changeset.commits.size}} to the First value field.
    2. Choose the does not equal option from the Condition dropdown.
    3. Enter "0" to the Second value field.
  7. Click Save.
  8. Click New action.
  9. Select the action Send email.
    1. Choose a recipient group or enter the addresses manually.
    2. Enter the following subject:
      [DEVOPS] {{devops.changeset.commits.size}} new commit{{#devops.changeset.commits}}{{^first}}{{#last}}s{{/}}{{/}}{{/}}{{^devops.changeset.commits}}s{{/}} in {{devops.changeset.repositoryId.htmlEncode}}
    3. Enter the following content (a very simple template you can easily customize to your needs):
      <p>
      	{{#issues.size}}
      		<b>{{issues.size}} issue{{#issues}}{{^first}}{{#last}}s{{/}}{{/}}{{/}}</b> linked:
      	{{/}}
      	{{^issues.size}}
      		No issues linked.
      	{{/}}
      </p>
      <ul>
      	{{#issues}}
      		<li><a href="{{url}}">{{key}}</a> {{summary.htmlEncode}}</li>
      	{{/}}
      </ul>
      {{#devops.changeset.commits}}
      	<p>&mdash;&mdash;&mdash;&mdash;&mdash;</p>
      	<p>Commit: <b>#{{id}}</b> &middot; Branch: <b>{{branch.htmlEncode}}</b> &middot; Author: <b>{{userName.htmlEncode}}</b></p>
      	<blockquote style="background:#f0f0f0; padding:0.2em">{{message.htmlEncode.replace("&#10;","<br>")}}</blockquote>
      	<p><b>{{files.size}} file{{#files}}{{^first}}{{#last}}s{{/}}{{/}}{{/}}{{^files}}s{{/}}</b> changed:</p>
      	<ul>
      		{{#files}}
      			<li><b><code style="color:{{action.color}}">{{action.label}}</code></b> {{path.htmlEncode}}</li>
      		{{/}}
      	</ul>
      {{/}}
      
      Notes:
      • Those smart values that can contain HTML-unsafe characters should be HTML-encoded with .htmlEncode.
      • Those smart values that can contain multi-line strings should be transformed with .replace("&#10;","<br>").
    4. Click More options.
    5. Choose HTML as format.
    6. Uncheck the Convert line breaks to HTML line breaks checkbox.
  10. Click Save.
  11. Name your automation rule intuitively, and click Turn it on.

Usage

  1. Create a commit in your repository with this message:
    Implement the FOO-1 feature.
  2. Then another with this:
    Fix the FOO-2 and FOO-3 bugs.
  3. An email will be sent to the selected recipients with the linked issue list and the commit details.

Troubleshooting

If you don't get the expected results:

  1. See the general troubleshooting steps.

Questions?

Ask us any time.