From a1c1c2ddec92faeb7c5299611797f286df073846 Mon Sep 17 00:00:00 2001 From: Michal Fasanek Date: Wed, 20 May 2026 10:48:59 +0200 Subject: [PATCH] Add Mattermost incoming webhooks integration Receive flag change notifications in Mattermost channels via Mattermost's incoming webhook feature. Uses the auditLogEventsHook capability with three templates (default, project, environment) targeting Mattermost's Slack-compatible attachment payload schema. All 2,387 tests in npm test pass, including JSON-validity checks across the project/environment/flag sample contexts. Co-authored-by: Cursor --- integrations/mattermost/LICENSE.md | 13 +++++ integrations/mattermost/README.md | 9 ++++ .../mattermost/assets/images/horizontal.svg | 1 + .../mattermost/assets/images/square.svg | 1 + integrations/mattermost/manifest.json | 54 +++++++++++++++++++ .../mattermost/templates/default.json.hbs | 19 +++++++ .../mattermost/templates/environment.json.hbs | 17 ++++++ .../mattermost/templates/project.json.hbs | 14 +++++ 8 files changed, 128 insertions(+) create mode 100644 integrations/mattermost/LICENSE.md create mode 100644 integrations/mattermost/README.md create mode 100644 integrations/mattermost/assets/images/horizontal.svg create mode 100644 integrations/mattermost/assets/images/square.svg create mode 100644 integrations/mattermost/manifest.json create mode 100644 integrations/mattermost/templates/default.json.hbs create mode 100644 integrations/mattermost/templates/environment.json.hbs create mode 100644 integrations/mattermost/templates/project.json.hbs diff --git a/integrations/mattermost/LICENSE.md b/integrations/mattermost/LICENSE.md new file mode 100644 index 00000000..b952ba71 --- /dev/null +++ b/integrations/mattermost/LICENSE.md @@ -0,0 +1,13 @@ +Copyright 2026 Catamorphic Co. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/integrations/mattermost/README.md b/integrations/mattermost/README.md new file mode 100644 index 00000000..bf0fd2a9 --- /dev/null +++ b/integrations/mattermost/README.md @@ -0,0 +1,9 @@ +# Mattermost + +User documentation for this integration is available on the LaunchDarkly documentation site: [Mattermost](https://launchdarkly.com/docs/integrations/mattermost) + +API documentation for this integration is available on Mattermost's documentation site: [Incoming webhooks for Mattermost](https://docs.mattermost.com/developer/webhooks-incoming.html) + +## Getting started with the Mattermost integration + +Run `npm run curl mattermost` in the root repository directory to generate a `curl` command to send data to Mattermost. diff --git a/integrations/mattermost/assets/images/horizontal.svg b/integrations/mattermost/assets/images/horizontal.svg new file mode 100644 index 00000000..3e6dc0f3 --- /dev/null +++ b/integrations/mattermost/assets/images/horizontal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/integrations/mattermost/assets/images/square.svg b/integrations/mattermost/assets/images/square.svg new file mode 100644 index 00000000..d185ef27 --- /dev/null +++ b/integrations/mattermost/assets/images/square.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/integrations/mattermost/manifest.json b/integrations/mattermost/manifest.json new file mode 100644 index 00000000..0b37ac53 --- /dev/null +++ b/integrations/mattermost/manifest.json @@ -0,0 +1,54 @@ +{ + "name": "Mattermost incoming webhooks", + "version": "1.0.0", + "overview": "Receive flag change notifications in your Mattermost channels.", + "description": "Receive LaunchDarkly notifications in your Mattermost channels. Subscribe to changes in flags, projects, environments, and other resources via Mattermost's incoming webhook integration.", + "author": "LaunchDarkly", + "supportEmail": "support@launchdarkly.com", + "links": { + "site": "https://mattermost.com", + "launchdarklyDocs": "https://launchdarkly.com/docs/integrations/mattermost", + "privacyPolicy": "https://mattermost.com/privacy-policy/" + }, + "categories": ["messaging"], + "icons": { + "square": "assets/images/square.svg", + "horizontal": "assets/images/horizontal.svg" + }, + "formVariables": [ + { + "key": "url", + "name": "Incoming webhook URL", + "type": "uri", + "description": "Enter your Mattermost [incoming webhook URL](https://docs.mattermost.com/developer/webhooks-incoming.html).", + "isSecret": false + } + ], + "capabilities": { + "auditLogEventsHook": { + "endpoint": { + "url": "{{{url}}}", + "method": "POST", + "headers": [ + { + "name": "Content-Type", + "value": "application/json" + } + ] + }, + "templates": { + "project": "templates/project.json.hbs", + "environment": "templates/environment.json.hbs", + "default": "templates/default.json.hbs", + "validation": "templates/default.json.hbs" + }, + "defaultPolicy": [ + { + "effect": "allow", + "resources": ["proj/*:env/production:flag/*"], + "actions": ["*"] + } + ] + } + } +} diff --git a/integrations/mattermost/templates/default.json.hbs b/integrations/mattermost/templates/default.json.hbs new file mode 100644 index 00000000..4ffb882f --- /dev/null +++ b/integrations/mattermost/templates/default.json.hbs @@ -0,0 +1,19 @@ +{ + "username": "LaunchDarkly", + "attachments": [ + { + "fallback": "{{{title.plainText}}}", + "color": "#405BFF", + "title": "{{{name}}}", + "title_link": "{{{_links.site.href}}}", + "text": "{{{title.markdown}}}{{#if details.markdown}}\n\n{{{details.markdown}}}{{/if}}{{#if comment}}\n\n**Comment:** {{{comment}}}{{/if}}", + "fields": [ + {{#if project.name}}{ "title": "Project", "value": "{{{project.name}}}", "short": true }, + {{/if}}{{#if project.environment.name}}{ "title": "Environment", "value": "{{{project.environment.name}}}", "short": true }, + {{/if}}{ "title": "Action", "value": "{{{verbKind}}}", "short": true } + ], + "footer": "LaunchDarkly", + "ts": {{timestamp.seconds}} + } + ] +} diff --git a/integrations/mattermost/templates/environment.json.hbs b/integrations/mattermost/templates/environment.json.hbs new file mode 100644 index 00000000..22269df6 --- /dev/null +++ b/integrations/mattermost/templates/environment.json.hbs @@ -0,0 +1,17 @@ +{ + "username": "LaunchDarkly", + "attachments": [ + { + "fallback": "{{{title.plainText}}}", + "color": "#405BFF", + "title": "{{{name}}}", + "title_link": "{{{_links.site.href}}}", + "text": "{{{title.markdown}}}{{#if details.markdown}}\n\n{{{details.markdown}}}{{/if}}{{#if comment}}\n\n**Comment:** {{{comment}}}{{/if}}", + "fields": [ + { "title": "Project", "value": "{{{project.name}}}", "short": true } + ], + "footer": "LaunchDarkly", + "ts": {{timestamp.seconds}} + } + ] +} diff --git a/integrations/mattermost/templates/project.json.hbs b/integrations/mattermost/templates/project.json.hbs new file mode 100644 index 00000000..b63f9baa --- /dev/null +++ b/integrations/mattermost/templates/project.json.hbs @@ -0,0 +1,14 @@ +{ + "username": "LaunchDarkly", + "attachments": [ + { + "fallback": "{{{title.plainText}}}", + "color": "#405BFF", + "title": "{{{name}}}", + "title_link": "{{{_links.site.href}}}", + "text": "{{{title.markdown}}}{{#if details.markdown}}\n\n{{{details.markdown}}}{{/if}}{{#if comment}}\n\n**Comment:** {{{comment}}}{{/if}}", + "footer": "LaunchDarkly", + "ts": {{timestamp.seconds}} + } + ] +}