Slack integration for deployments via Capistrano

Updated . Posted . Visible to the public.

You can hook into Slack Show archive.org snapshot when using Capistrano for deployment. The slackistrano Show archive.org snapshot gem does most of the heavy lifting for you. Its default messages are unobtrusive and can be adjusted easily.

When deploying, it posts to a Slack channel like this:

Example

How to integrate

Integrating Slackistrano with Capistrano 3 is fairly simple.

  1. In your Slack, open menu → Administration → Manage apps, and add an "Incoming WebHooks" Show archive.org snapshot integration.

  2. Choose channel, and add the app.

  3. Set a name and save. This will not be used for notifications, but clarifies the webhook's purpose when browsing the list of integrations.

  4. Copy your "Webhook URL".

  5. Add slackistrano to your Gemfile, in your :deploy group, and bundle your project.

  6. Add the following to your Capfile.

    # Slack notifications
    require 'slackistrano/capistrano'
    set :slackistrano, {
      channel: '#your-channel',
      webhook: 'https://hooks.slack.com/services/your/webhook/url',
    }
    
  7. Optional: Tweak your deployment messages Show archive.org snapshot . See the attached file for our default message formatting. Your Capfile needs to be adjusted accordingly:

    # Slack notifications
    require 'slackistrano/capistrano'
    require_relative 'lib/capistrano/slackistrano'
    set :slackistrano, {
      klass: Slackistrano::CustomMessaging,
      channel: '#your-channel',
      webhook: 'https://hooks.slack.com/services/your/webhook/url',
    }
    
  8. Test Slackistrano:

    cap staging slack:deploy:test
    
  9. When you are satisfied, do a real deploy to confirm everything works.

Arne Hartherz
Last edit
Johanna Schalk
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2015-03-19 17:33)