Class: Fastlane::Notification::Slack

Inherits:
Object
  • Object
show all
Defined in:
fastlane/lib/fastlane/notification/slack.rb

Defined Under Namespace

Classes: LinkConverter

Instance Method Summary collapse

Constructor Details

#initialize(webhook_url) ⇒ Slack

Returns a new instance of Slack.



4
5
6
7
8
9
# 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

Instance Method Details

#post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:) ⇒ Object

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



14
15
16
17
18
19
20
21
22
23
24
25
# 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