Sha256: d5e799add52b4a9992b28e191baa3c0a24ac7bffe2746d62b4fa72161c01969b

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

namespace :ci do
  namespace :slack do
    desc 'Set up Slack'
    task :setup do
      @attachments = []

      ENV['SLACK_WEBHOOK_URL'] ||= ask('Slack Webhook URL: ')
      ENV['SLACK_WEBHOOK_URL'] = nil if ENV['SLACK_WEBHOOK_URL'] == ''

      ENV['SLACK_CHANNEL'] ||= ask('Slack Channel: ')
      ENV['SLACK_CHANNEL'] = nil if ENV['SLACK_CHANNEL'] == ''
    end

    desc 'publish'
    task publish: :setup do
      next if @attachments.empty? || ENV['SLACK_WEBHOOK_URL'].nil?

      require 'ndr_dev_support/slack_message_publisher'

      # We have attachments so prepend them with basic commit details
      Rake::Task['ci:rugged:commit_details'].invoke

      slack_publisher = NdrDevSupport::SlackMessagePublisher.new(ENV['SLACK_WEBHOOK_URL'],
                                                                 username: 'Rake CI',
                                                                 icon_emoji: ':robot_face:',
                                                                 channel: ENV['SLACK_CHANNEL'])
      slack_publisher.post(attachments: @attachments)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ndr_dev_support-4.0.0 lib/tasks/ci/slack.rake
ndr_dev_support-3.1.3 lib/tasks/ci/slack.rake
ndr_dev_support-3.1.2 lib/tasks/ci/slack.rake
ndr_dev_support-3.1.1 lib/tasks/ci/slack.rake
ndr_dev_support-3.1.0 lib/tasks/ci/slack.rake
ndr_dev_support-3.0.0 lib/tasks/ci/slack.rake