Mattermost Integration
BETA
Mattermost is an open source messaging platform that enables secure team collaboration. It competes with Slack but allows different hosting options, including self-hosting.
JEMHCloud supports Mattermost notifications from Issue Events and Post Functions. You will be able to notify your Mattermost Channels when JEMHC detects an issue change.
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.
Log into your Mattermost instance.
Click on Integrations → Incoming Webhook
Create a new Incoming Webhook and select the channel target of JEMHCloud Mattermost notifications.
Copy the URL. You will use this URL when creating the a Mattermost Connection
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
Go to JEMHCloud → Messages → Mattermost Connections
Click on Create button.
Once in the Mattermost Connection form, enter a name and paste the Incoming Webhook URL copied from Mattermost's Integrations page.
Submit. If the configuration is ok, you should see a test message in Mattermost's channel
Create JEMHCloud's Mattermost Notification Mapping
Like Email and SMS Notification Mapping, Mattermost Notification Mapping is in charge of sending Mattermost messages from Issue events through the Mattermost Connection.
Creating a Mattermost Notification Mapping:
Go to JEMH Cloud → Notifications → Mattermost → Create
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).
On Submit, you should see the new Mattermost mapping
To test the mapping, create an issue in the nominated project and go to Auditing → Events
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
The report of the event should confirm the message sent
In Auditing → Outbound Messages → Type Mattermost, the table should show the Mattermost messages sent and the cog icon should show their contents.
Send Mattermost Notifications from Post Functions
JEMHCloud allows you to send Mattermost notifications when Issue transitions are performed through JIRA Post Functions.
Adding the Mattermost Notification Post Function to workflow transition:
Go to right corner Cog → JIRA Administration → Issue → Workflows. Edit the workflow of the project you want to add the Post Function
Click on the transition you want to change and select the Post Functions tab. Click on Add post function
Select Send Mattermost Notification by JEMHCloud and click Add
Set the Mattermost Connection and Velocity script if necessary. Press Add/Update
Once the Post Function is in the right position, publish the workflow draft.
To test the post function, go to an issue of the given workflow and perform the transition that will fire the post function.
Post function event should appear in JEMH Cloud → Notifications → Events.
The event report should show the used incoming webhook URL (part of the URL is hashed for security reasons)
The message in Mattermost:
In Auditing → Outbound Messages, the table should show the Mattermost messages sent and the cog icon should show their contents.
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
#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
#if (!$dateTimeUtils.betweenHours("18:00", "06:00"))
$mattermostNotificationUtils.inhibitNotification() ## mattermost messages are not sent during business hours **
#end
Restrict by priority
#if ($context.issue.fields.priority.name.textValue() != 'Blocker')
$mattermostNotificationUtils.inhibitNotification()
#end
Velocity Script cannot be validated at configuration time (for example the dynamic incoming webhook URL). You should test the script by re-executing events in Auditing → Events