Read more

Slack integration for deployments via Capistrano

Arne Hartherz
March 19, 2015Software engineer at makandra GmbH

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.

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

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
March 19, 2015Software engineer at makandra GmbH
Posted by Arne Hartherz to makandra dev (2015-03-19 18:33)