BigW Consortium Gitlab

slack_service.rb 1.2 KB
Newer Older
1
class SlackService < ChatNotificationService
2
  def title
3
    'Slack notifications'
4 5 6
  end

  def description
7
    'Receive event notifications in Slack'
8 9
  end

10
  def self.to_param
11
    'slack'
12 13
  end

14
  def help
15
    'This service sends notifications about projects events to Slack channels.<br />
16
    To set up this service:
17
    <ol>
18 19 20
      <li><a href="https://slack.com/apps/A0F7XDUAZ-incoming-webhooks">Add an incoming webhook</a> in your Slack team. The default channel can be overridden for each event.</li>
      <li>Paste the <strong>Webhook URL</strong> into the field below.</li>
      <li>Select events below to enable notifications. The <strong>Channel name</strong> and <strong>Username</strong> fields are optional.</li>
21
    </ol>'
22 23
  end

24
  def fields
25
    default_fields + build_event_channels
26 27
  end

28 29
  def default_fields
    [
30 31
      { type: 'text', name: 'webhook', placeholder: 'e.g. https://hooks.slack.com/services/…' },
      { type: 'text', name: 'username', placeholder: 'e.g. GitLab' },
32 33 34
      { type: 'checkbox', name: 'notify_only_broken_builds' },
      { type: 'checkbox', name: 'notify_only_broken_pipelines' },
    ]
35 36
  end

37
  def default_channel_placeholder
38
    "Channel name (e.g. general)"
39
  end
40
end