Mattermost Recipe
require 'contrib/mattermost.php';
Installing
Create a Mattermost incoming webhook, through the administration panel. Add hook on deploy:
before('deploy', 'mattermost:notify');
Configuration
mattermost_webhook
- incoming mattermost webook requiredset('mattermost_webook', 'https://{your-mattermost-site}/hooks/xxx-generatedkey-xxx');
mattermost_channel
- overrides the channel the message posts inset('mattermost_channel', 'town-square');
mattermost_username
- overrides the username the message posts asset('mattermost_username', 'deployer');
mattermost_icon_url
- overrides the profile picture the message posts withset('mattermost_icon_url', 'https://domain.com/your-icon.png');
mattermost_text
- notification messageset('mattermost_text', '_{{user}}_ deploying `{{what}}` to **{{where}}**');
mattermost_success_text
– success template, default:set('mattermost_success_text', 'Deploy to **{{where}}** successful {{mattermost_success_emoji}}');
mattermost_failure_text
– failure template, default:set('mattermost_failure_text', 'Deploy to **{{where}}** failed {{mattermost_failure_emoji}}');
mattermost_success_emoji
– emoji added at the end of success textmattermost_failure_emoji
– emoji added at the end of failure text For detailed information about Mattermost hooks see: https://developers.mattermost.com/integrate/incoming-webhooks/
Usage
If you want to notify only about beginning of deployment add this line only:
before('deploy', 'mattermost:notify');
If you want to notify about successful end of deployment add this too:
after('deploy:success', 'mattermost:notify:success');
If you want to notify about failed deployment add this too:
after('deploy:failed', 'mattermost:notify:failure');
Configuration
mattermost_webhook
Default value
null
mattermost_channel
Default value
null
mattermost_username
Default value
'deployer'
mattermost_icon_url
Default value
null
mattermost_success_emoji
Default value
':​white_check_mark:'
mattermost_failure_emoji
Default value
':​x:'
mattermost_text
Default value
'_{{user}}_ deploying `{{what}}` to **{{where}}**'
mattermost_success_text
Default value
'Deploy to **{{where}}** successful {{mattermost_success_emoji}}'
mattermost_failure_text
Default value
'Deploy to **{{where}}** failed {{mattermost_failure_emoji}}'
Tasks
mattermost:notify
Notifies mattermost.
mattermost:notify:success
Notifies mattermost about deploy finish.
mattermost:notify:failure
Notifies mattermost about deploy failure.