phallstrom / slackistrano

Slack integration for Capistrano deployments.
MIT License
374 stars 74 forks source link

customizations failing in beta #54

Closed chrishough closed 8 years ago

chrishough commented 8 years ago

I am trying to literally copy and paste your example custom message and I am getting the following:

(Backtrace restricted to imported tasks)
cap aborted!
SocketError: getaddrinfo: nodename nor servname provided, or not known

Tasks: TOP => rbenv:validate
(See full trace by running task with —trace)

I have tried using the slackbot and incoming hook urls. Both no luck.

chrishough commented 8 years ago

After a bit of tweaking I was able to get the testing message to pass... not sure what could have caused this.

module Slackistrano
  class CustomMessaging < Messaging::Base
    def channels_for(action)
      super
    end

    # Supress updating message.
    def payload_for_updating
      nil
    end

    # Supress reverting message.
    def payload_for_reverting
      nil
    end

    # Fancy updated message.
    # See https://api.slack.com/docs/message-attachments
    # rubocop:disable Metrics/MethodLength
    def payload_for_updated
      {
        attachments: [{
          color: 'good',
          title: 'Integrations Application Deployed :boom:',
          fields: [{
            title: 'Environment',
            value: stage,
            short: true
          }, {
            title: 'Branch',
            value: branch,
            short: true
          }, {
            title: 'Deployer',
            value: deployer,
            short: true
          }, {
            title: 'Time',
            value: elapsed_time,
            short: true
          }],
          fallback: super[:text]
        }]
      }
    end
    # rubocop:enable all

    def payload_for_reverted
      super
    end

    # Slightly tweaked failed message.
    # See https://api.slack.com/docs/message-formatting
    def payload_for_failed
      payload = super
      payload[:text] = ":fire: #{payload[:text]}"
      payload
    end

    # Override the deployer helper to pull the full name from the password file.
    # See https://github.com/phallstrom/slackistrano/blob/master/lib/slackistrano/messaging/helpers.rb
    def deployer
      Etc.getpwnam(ENV['USER']).gecos
    end
  end
end
chrishough commented 8 years ago

Also, I adjusted this to pass all rubocop styleguide issues

phallstrom commented 8 years ago

@chrishough Just to be clear.. you got it working without having to fix the above class or did I have a mistake in the example?

Also, are you using the default rubocop or do you have special rules? I keep meaning to apply them and keep forgetting :)

chrishough commented 8 years ago

I updated the setup here for you: https://github.com/phallstrom/slackistrano/pull/55

I think my error was related to not having the #ops channel you had setup. My example takes that out for others but it would be worth noting those channels need to exist for the test to pass as the test creates an example for each.