##// END OF EJS Templates
dependencies: bumped docutils to 0.14.0
dependencies: bumped docutils to 0.14.0

File last commit:

r552:9a0f45b0 default
r2283:1e3f0cd9 default
Show More
int-slack.rst
151 lines | 5.1 KiB | text/x-rst | RstLexer

Integrate Slack

To integrate |RCE| and Slack, you need to configure some things on the Slack side of the integration, and some things on the |RCE| side.

On the Slack side you need to allow incoming webhooks, see their documentation on this, Slack Webhooks. You will also need to get an Authorization Token from Slack that will allow |RCE| to post to your account.

On the |RCE| side, this is an overview of what you need to do:

  1. Configure the built-in Slack extensions to post to the correct Slack URL.
  2. Set your Slack authentication details in the |RCX| :file:`__init.py__` file.
  3. Configure the different hooks in the :file:`__init.py__` file to extract whatever information you want from |RCE|, and then using the Slack extensions post that information to your Slack channel.

Hint

The below examples should help you to get started. Once you have your integration up and running, there is a more detailed Slack integration in the :ref:`int-full-blown` section.

Configure Built-in Extensions

|RCE| comes with 3 Slack extensions: slack_message.py, slack_push_notify.py, and slack.py. The default location is :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions`.

To enable these to post to your Slack account, configure each of these files with the following Slack details.

BASE_URL = 'https://your.slack.com/api/link'
INCOMING_WEBHOOK_URL = 'https://hooks.slack.com/services/your/hook/link'
API_VERSION = 1

Configure |RCE| to Post to Slack

In the |RCX| :file:`__init.py__` file, configure your Slack authentication details. The default location is :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions`

CONFIG = DotDict(
    slack=DotDict(
        api_key='api-key',
        api_url='slack-incoming-hook-url',
        default_room='#slack-channel',
        default_plugin_config={},
    ),
)

# slack conf
CONFIG.slack.default_plugin_config = {
    'INCOMING_WEBHOOK_URL': CONFIG.slack.api_url,
    'SLACK_TOKEN': CONFIG.slack.api_key,
    'SLACK_ROOM': CONFIG.slack.default_room,
    'SLACK_FROM': 'RhodeCode',
    'SLACK_FROM_ICON_EMOJI': ':rhodecode:',
}

Add Push Notifications to Slack

To add notification to Slack when someone pushes to |RCE|, configure the push hook to extract the commits pushed, and then call the built-in slack_push_notify.py extension to post them into your chosen Slack channel. To do this, add the following code to the push hook section of the :file:`__init.py__` file

Add Pull Request Notifications to Slack

To add |pr| notifications to Slack, use the following example. This example shows a merged |pr| notification. You can add similar notifications to the following hooks in the :file:`__init.py__` file, and for those examples see the :ref:`int-full-blown` section:

  • _create_pull_request_hook
  • _review_pull_request_hook
  • _update_pull_request_hook
  • _close_pull_request_hook