class Fastlane::Notification::Slack

Public Class Methods

new(webhook_url) click to toggle source
# File fastlane/lib/fastlane/notification/slack.rb, line 4
def initialize(webhook_url)
  @webhook_url = webhook_url
  @client = Faraday.new do |conn|
    conn.use(Faraday::Response::RaiseError)
  end
end

Public Instance Methods

post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:) click to toggle source

Overriding channel, icon_url and username is only supported in legacy incoming webhook. Also note that the use of attachments has been discouraged by Slack, in favor of Block Kit. api.slack.com/legacy/custom-integrations/messaging/webhooks

# File fastlane/lib/fastlane/notification/slack.rb, line 14
def post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:)
  @client.post(@webhook_url) do |request|
    request.headers['Content-Type'] = 'application/json'
    request.body = {
      channel: channel,
      username: username,
      icon_url: icon_url,
      attachments: attachments,
      link_names: link_names
    }.to_json
  end
end