Slack Recipe
require 'contrib/slack.php';
Installing
before('deploy', 'slack:notify');
Configuration
slack_webhook
– slack incoming webhook url, requiredset('slack_webhook', 'https://hooks.slack.com/...');
slack_channel
- channel to send notification to. The default is the channel configured in the webhookslack_title
– the title of application, default{{application}}
slack_text
– notification message template, markdown supportedset('slack_text', '_{{user}}_ deploying `{{what}}` to *{{where}}*');
slack_success_text
– success template, default:set('slack_success_text', 'Deploy to *{{where}}* successful');
slack_failure_text
– failure template, default:set('slack_failure_text', 'Deploy to *{{where}}* failed');
slack_color
– color's attachmentslack_success_color
– success color's attachmentslack_failure_color
– failure color's attachmentslack_fields
- set attachments fields for pretty output in Slack, default:set('slack_fields', []);
Usage
If you want to notify only about beginning of deployment add this line only:
before('deploy', 'slack:notify');
If you want to notify about successful end of deployment add this too:
after('deploy:success', 'slack:notify:success');
If you want to notify about failed deployment add this too:
after('deploy:failed', 'slack:notify:failure');
Configuration
slack_channel
Channel to publish to, when false the default channel the webhook will be used
Default value
false
slack_title
Title of project
Default value
return get('application', 'Project');
slack_text
Deploy message
Default value
'_{{user}}_ deploying `{{what}}` to *{{where}}*'
slack_success_text
Default value
'Deploy to *{{where}}* successful'
slack_failure_text
Default value
'Deploy to *{{where}}* failed'
slack_rollback_text
Default value
'_{{user}}_ rolled back changes on *{{where}}*'
slack_fields
slack_color
Color of attachment
Default value
'#4d91f7'
slack_success_color
Default value
'#00c100'
slack_failure_color
Default value
'#ff0909'
slack_rollback_color
Default value
'#eba211'
Tasks
slack:notify
Notifies Slack.
slack:notify:success
Notifies Slack about deploy finish.
slack:notify:failure
Notifies Slack about deploy failure.
slack:notify:rollback
Notifies Slack about rollback.