How to send messages to Mattermost using user plugin

How to send messages to Mattermost using user plugin

AuthorFullName__c
Hirofumi Iwashita
articleNumber
000004824
ft:sourceType
Salesforce
FirstPublishedDate
2020-12-07T15:30:42Z
lastModifiedDate
2021-09-01
VersionNumber
4

Artifactory doesn't natively support the webhook but if you want to trigger some actions by creating artifacts etc, it is possible by using Artifactory Webhook Plugin.
In this time, we introduce how to send messages to Mattermost which is one of the Slack clone.

1. Configure Incoming Webhooks
Regarding Slack, it is written in Artifactory Webhook Plugin but please refer to Incoming Webhooks for Mattermost.

2. Configure webhook.config.json
The url value needs to be changed to the value provided by Incoming Webhooks. The format value should be specified as "slack" because They payload of Mattermost and Slack are compatibility. About the other elements, please refer to Artifactory Webhook Plugin.

{
        "webhooks": {
                "slack": {
                        "url": "http://mattermost:8065/hooks/########-####-####-####-############",
                        "events": [
                                "execute.pingWebhook",
                                "storage.afterCreate",
                                "storage.afterDelete",
                                "storage.afterMove",
                                "storage.afterCopy",
                                "storage.afterPropertyCreate",
                                "storage.afterPropertyDelete"
                        ],
                        "format": "slack",
                        "async": false,
                        "repositories": [
                                "vendor-distributions"
                        ]
                }
        }
}

3. Save webhook.groovy and webhook.config.json
Please save webhook.groovy and webhook.config.json in plugins directory. The permission should be the same as the other plugins.

4. Reload Plugin
Please load it using Reload Plugins REST API. If you need to change webhook.config.json, you can use webhookReload method written in Artifactory Webhook Plugin.

5. Confirm message
The following example was sent by deploying node_init.sh file to vendor-distributions repository.
User-added image