gitlab-org--gitlab-foss/app/models/project_services/slack_service.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

class SlackService < ChatNotificationService
2014-03-18 13:27:03 -04:00
def title
2016-11-25 14:36:37 -05:00
'Slack notifications'
2014-03-18 13:27:03 -04:00
end
def description
2016-11-25 14:36:37 -05:00
'Receive event notifications in Slack'
2014-03-18 13:27:03 -04:00
end
def self.to_param
'slack'
2014-03-18 13:27:03 -04:00
end
def help
2016-11-25 14:36:37 -05:00
'This service sends notifications about projects events to Slack channels.<br />
To set up this service:
2016-11-25 14:36:37 -05:00
<ol>
<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>
2016-11-25 14:36:37 -05:00
</ol>'
end
2014-03-18 13:27:03 -04:00
def fields
default_fields + build_event_channels
2014-03-18 13:27:03 -04:00
end
2016-11-25 14:36:37 -05:00
def default_fields
[
{ type: 'text', name: 'webhook', placeholder: 'e.g. https://hooks.slack.com/services/…' },
{ type: 'text', name: 'username', placeholder: 'e.g. GitLab' },
2016-11-25 14:36:37 -05:00
{ type: 'checkbox', name: 'notify_only_broken_pipelines' },
]
2016-07-13 15:49:47 -04:00
end
def default_channel_placeholder
"Channel name (e.g. general)"
end
2014-03-18 13:27:03 -04:00
end