Back to Deployer

Slack Recipe

docs/contrib/slack.md

8.0.34.5 KB
Original Source
<!-- DO NOT EDIT THIS FILE! --> <!-- Instead edit contrib/slack.php --> <!-- Then run bin/docgen -->

Slack Recipe

php
require 'contrib/slack.php';

Source

Installing

<a href="https://slack.com/oauth/authorize?&client_id=113734341365.225973502034&scope=incoming-webhook"></a> Add hook on deploy:

php
before('deploy', 'slack:notify');

Configuration

  • slack_webhook – slack incoming webhook url, required
    set('slack_webhook', 'https://hooks.slack.com/...');
    
  • slack_channel - channel to send notification to. The default is the channel configured in the webhook
  • slack_title – the title of application, default {{application}}
  • slack_text – notification message template, markdown supported
    set('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 attachment
  • slack_success_color – success color's attachment
  • slack_failure_color – failure color's attachment
  • slack_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:

php
before('deploy', 'slack:notify');

If you want to notify about successful end of deployment add this too:

php
after('deploy:success', 'slack:notify:success');

If you want to notify about failed deployment add this too:

php
after('deploy:failed', 'slack:notify:failure');

Configuration

slack_channel

Source

Channel to publish to, when false the default channel the webhook will be used

php
false

slack_title

Source

Title of project

php
return get('application', 'Project');

slack_text

Source

Deploy message

php
'_{{user}}_ deploying `{{what}}` to *{{where}}*'

slack_success_text

Source

php
'Deploy to *{{where}}* successful'

slack_failure_text

Source

php
'Deploy to *{{where}}* failed'

slack_rollback_text

Source

php
'_{{user}}_ rolled back changes on *{{where}}*'

slack_fields

Source

slack_color

Source

Color of attachment

php
'#4d91f7'

slack_success_color

Source

php
'#00c100'

slack_failure_color

Source

php
'#ff0909'

slack_rollback_color

Source

php
'#eba211'

Tasks

slack:notify {#slack-notify}

Source

Notifies Slack.

slack:notify:success {#slack-notify-success}

Source

Notifies Slack about deploy finish.

slack:notify:failure {#slack-notify-failure}

Source

Notifies Slack about deploy failure.

slack:notify:rollback {#slack-notify-rollback}

Source

Notifies Slack about rollback.