In this page

Sending a Slack message about a new changeset

Slack is a leading workplace communications platform, offering chat rooms (channels) organized by topic, private groups, and direct messaging. Slack is a strategic partner of Atlassian and a preferred instant messaging platform in the Atlassian Ecosystem.

This automation sends a notification message to a Slack channel about the changeset after that has been accepted by the repository:

The message content can be freely customized, allowing you to post anything from short summaries to longer details.

Configuration

  1. Login into your Slack account.
  2. Go to Incoming WebHooks.
    1. Choose the default channel for the messages.
    2. Click Add Incoming WebHooks integration.
    3. Copy the Webhook URL to clipboard.
  3. Login to Jira as admin, go to AdministrationSystemAutomation rules.
  4. Click Create rule.
  5. Select the trigger Changeset accepted (from the DevOps category).
  6. Click Save.
  7. Click Add component and select New condition.
  8. 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.
  9. Click Save.
  10. Click New action.
  11. Select the action Send Slack message.
    1. Paste the Webhook URL you just configured.
    2. Enter the following content into the Message field:
      _[DEVOPS] {{devops.changeset.commits.size}} new commit{{#devops.changeset.commits}}{{^first}}{{#last}}s{{/}}{{/}}{{/}}{{^devops.changeset.commits}}s{{/}} in {{devops.changeset.repositoryId}}_
      
      {{#issues.size}}
      *{{issues.size}} issue{{#issues}}{{^first}}{{#last}}s{{/}}{{/}}{{/}}* linked:
      {{/}}
      {{^issues.size}}
      No issues linked.
      {{/}}
      {{#issues}}
      <{{url}}|{{key}}> {{summary}}
      {{/}}
      {{#devops.changeset.commits}}
      
      —————
      
      Commit: *#{{id}}* · Branch: *{{branch}}* · Author: *{{userName}}*
      
      >{{message.replace("\n","\n>")}}
      
      *{{files.size}} file{{#files}}{{^first}}{{#last}}s{{/}}{{/}}{{/}}{{^files}}s{{/}}* changed:
      {{#files}}
      `{{action.label}}` {{path}}
      {{/}}
      {{/}}
      
      Notes:
    3. Override Channel or user or leave as default as you set it in step 2.
  12. Click Save.
  13. 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. A Slack message will be sent to the selected channel 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.