Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Status
colourYellow
titleBETA

Table of Contents

Mattermost is an open source messaging platform that enables secure team collaboration. It competes with Slack but allows different hosting options, including self-hosting. 

...

Configuring the Mattermost Connection

In order to send Mattermost notifications from Issue and Post function events, you need to set up an Incoming Webhook URL in Mattermost. Once you have the Incoming Webhook URL, JEMHCloud's Matttermost connection will use that URL to send messages to the selected channel.

Configure Mattermost's Incoming Webhook URL

For this step, we are assuming that you have a mattermost server already configured. To install Mattermost, follow Mattermost's gettings starting guide.

  1. Log into your Mattermost instance. 

  2. Click on Integrations → Incoming Webhook

...

  1. Image Added

...

  1. Image Added
  2. Create a new Incoming Webhook and select the channel target of JEMHCloud Mattermost notifications.

...

  1. Image Added
  2. Copy the URL. You will use this URL when creating the a Mattermost Connection

...

  1. Image Added


Info

Note: The author of the message will the user that created the Incoming Webhook. If you want a different more generic name, you would need to create the incoming webhook when logged in as a different bot user (for example Jira or JEMHC)

Create JEMHCloud's Mattermost Connection

  1. Go to JEMHCloud → Messages → Mattermost Connections

  2. Click on Create button.

  3. Once in the Mattermost Connection form, enter a name and paste the Incoming Webhook URL copied from Mattermost's Integrations page.

...

  1. Image Added
  2. Submit. If the configuration is ok, you should see a test message in Mattermost's channel

...

  1. Image Added

...

  1. Image Added

Create JEMHCloud's Mattermost Notification Mapping

...

Creating a Mattermost Notification Mapping:

  1. Go to JEMH Cloud → Notifications → Mattermost → Create

  2. Complete the form, select the nominated projects and select the Mattermost Connection. Enter a velocity script if you want to modify the notification behavior at runtime (more below).

...

  1. Image Added
  2. On Submit, you should see the new Mattermost mapping

...

  1. Image Added
  2. To test the mapping, create an issue in the nominated project and go to Auditing → Events

  3. You should see the issue created event in the queue. When the event has been processed, the configured channel in the mapping should have received a Mattermost message

...

  1. Image Added

...

  1. Image Added

...

  1. Image Added
  2. The report of the event should confirm the message sent 

...

  1. Image Added
  2. In Auditing → Outbound Messages → Type Mattermost, the table should show

...

  1. the Mattermost messages sent and the cog icon should show their contents.

...

  1. Image Added

...

  1. Image Added

Send Mattermost Notifications from Post Functions

...

Adding the Mattermost Notification Post Function to workflow transition:

  1. Go to right corner Cog → JIRA Administration → Issue → Workflows. Edit the workflow of the project you want to add the Post Function

...

  1. Image Added
  2. Click on the transition you want to change and select the Post Functions tab. Click on Add post function

...

  1. Image Added
  2. Select Send Mattermost Notification by JEMHCloud and click Add

...

  1. Image Added
  2. Set the Mattermost Connection and Velocity script if necessary. Press Add/Update

...

  1. Image Added
  2. Once the Post Function is in the right position, publish the workflow draft.

...

  1. Image Added
  2. To test the post function, go to an issue of the given workflow and perform the transition that will fire the post function.

...

  1. Image Added
  2. Post function event should appear in JEMH Cloud → Notifications → Events.

...

  1. Image Added
  2. The event report should show the used incoming webhook URL (part of the URL is hashed for security reasons)

...

  1. Image Added
  2. The message in Mattermost:

...

  1. Image Added
  2. In Auditing → Outbound Messages, the table should show the Mattermost messages sent and the cog icon should show their contents.

...

  1. Image Added

...

  1. Image Added

Filter Scripts

Both Mattermost Notification Mapping and Mattermost Post Function behavior can be changed at runtime with a Velocity Script. The script can use the event data or be time-based to change how notifications are performed.

Change Channel

...

Change channel when Critical
Code Block
#if ($context.issue.fields.priority.name.textValue() != 'Critical')
  $mattermostNotificationUtils.setIncomingWebhookUrl('https://mattermost-thepluginpeople.ngrok.io/hooks/someOtherURL') ## JEMHC to send the message to a incoming webhook / channel defined at runtime
#end

Restrict notifications to specific time ranges

...

...

Notify only after hours
Code Block
#if (!$dateTimeUtils.betweenHours("18:00", "06:00"))
   $mattermostNotificationUtils.inhibitNotification() ## mattermost messages are not sent during business hours **
#end

Restrict by priority

No Formatcode
#if ($context.issue.fields.priority.name.textValue() != 'Blocker')
   $mattermostNotificationUtils.inhibitNotification()
#end

...

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@43352ed
sortmodified
showSpacefalsesortmodified
reversetrue
typepage
cqllabel in ( "notifcations" , "mattermost" ) and type = "page" and space = "JEMHC"
labelsmattermost notifcations

...

Page Properties
hiddentrue


Related issues