2017-08-17 22:00:37 +05:30
|
|
|
# Slack Notifications Service
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
The Slack Notifications Service allows your GitLab project to send events
|
|
|
|
(such as issue creation) to your existing Slack team as notifications. Setting up
|
|
|
|
Slack notifications requires configuration changes for both Slack and GitLab.
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
NOTE: **Note:**
|
|
|
|
You can also use Slack slash commands to control GitLab inside Slack. This is the
|
|
|
|
separately configured [Slack slash commands](slack_slash_commands.md).
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
## Slack configuration
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
1. Sign in to your Slack team and [start a new Incoming WebHooks configuration](https://my.slack.com/services/new/incoming-webhook).
|
2020-07-28 23:09:34 +05:30
|
|
|
1. Select the Slack channel where notifications will be sent to by default.
|
|
|
|
Click the **Add Incoming WebHooks integration** button to add the configuration.
|
|
|
|
1. Copy the **Webhook URL**, which we will use later in the GitLab configuration.
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
## GitLab configuration
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
1. Open your project's page, and navigate to your project's
|
|
|
|
[Integrations page](overview.md#accessing-integrations) at
|
|
|
|
**{settings}** **Settings > Integrations**.
|
2020-04-22 19:07:51 +05:30
|
|
|
1. Select the **Slack notifications** integration to configure it.
|
2020-07-28 23:09:34 +05:30
|
|
|
1. Click **Enable integration**.
|
|
|
|
1. In **Trigger**, select the checkboxes for each type of GitLab event to send to Slack as a
|
|
|
|
notification. See [Triggers available for Slack notifications](#triggers-available-for-slack-notifications)
|
|
|
|
for a full list. By default, messages are sent to the channel you configured during
|
|
|
|
[Slack integration](#slack-configuration).
|
|
|
|
1. (Optional) To send messages to a different channel, multiple channels, or as a direct message:
|
|
|
|
- To send messages to channels, enter the Slack channel names, separated by commas.
|
|
|
|
- To send direct messages, use the Member ID found in the user's Slack profile.
|
|
|
|
|
|
|
|
NOTE: **Note:**
|
|
|
|
Usernames and private channels are not supported.
|
|
|
|
|
|
|
|
1. In **Webhook**, provide the webhook URL that you copied from the
|
|
|
|
[Slack integration](#slack-configuration) step.
|
|
|
|
1. (Optional) In **Username**, provide the username of the Slack bot that sends the notifications.
|
|
|
|
1. Select the **Notify only broken pipelines** check box to only notify on failures.
|
|
|
|
1. In the **Branches to be notified** select box, choose which types of branches
|
|
|
|
to send notifications for.
|
|
|
|
1. Click **Test settings and save changes**.
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
Your Slack team will now start receiving GitLab event notifications as configured.
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
### Triggers available for Slack notifications
|
|
|
|
|
|
|
|
The following triggers are available for Slack notifications:
|
|
|
|
|
|
|
|
- **Push**: Triggered by a push to the repository.
|
|
|
|
- **Issue**: Triggered when an issue is created, updated, or closed.
|
|
|
|
- **Confidential issue**: Triggered when a confidential issue is created,
|
|
|
|
updated, or closed.
|
|
|
|
- **Merge request**: Triggered when a merge request is created, updated, or
|
|
|
|
merged.
|
|
|
|
- **Note**: Triggered when someone adds a comment.
|
|
|
|
- **Confidential note**: Triggered when someone adds a confidential note.
|
|
|
|
- **Tag push**: Triggered when a new tag is pushed to the repository.
|
|
|
|
- **Pipeline**: Triggered when a pipeline status changes.
|
|
|
|
- **Wiki page**: Triggered when a wiki page is created or updated.
|
|
|
|
- **Deployment**: Triggered when a deployment finishes.
|
|
|
|
- **Alert**: Triggered when a new, unique alert is recorded.
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
If your Slack integration is not working, start troubleshooting by
|
2019-03-02 22:35:43 +05:30
|
|
|
searching through the [Sidekiq logs](../../../administration/logs.md#sidekiqlog)
|
|
|
|
for errors relating to your Slack service.
|
|
|
|
|
|
|
|
### Something went wrong on our end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
This is a generic error shown in the GitLab UI and does not mean much by itself.
|
|
|
|
Review [the logs](../../../administration/logs.md#productionlog) to find
|
2019-03-02 22:35:43 +05:30
|
|
|
an error message and keep troubleshooting from there.
|
|
|
|
|
|
|
|
### `certificate verify failed`
|
|
|
|
|
|
|
|
You may see an entry similar to the following in your Sidekiq log:
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
```plaintext
|
2019-03-02 22:35:43 +05:30
|
|
|
2019-01-10_13:22:08.42572 2019-01-10T13:22:08.425Z 6877 TID-abcdefg ProjectServiceWorker JID-3bade5fb3dd47a85db6d78c5 ERROR: {:class=>"ProjectServiceWorker", :service_class=>"SlackService", :message=>"SSL_connect returned=1 errno=0 state=error: certificate verify failed"}
|
|
|
|
```
|
|
|
|
|
|
|
|
This is probably a problem either with GitLab communicating with Slack, or GitLab
|
|
|
|
communicating with itself. The former is less likely since Slack's security certificates
|
|
|
|
should _hopefully_ always be trusted. We can establish which we're dealing with by using
|
|
|
|
the below rails console script.
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
```shell
|
2019-03-02 22:35:43 +05:30
|
|
|
# start a rails console:
|
2020-04-08 14:13:33 +05:30
|
|
|
sudo gitlab-rails console -e production
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
# or for source installs:
|
2020-04-08 14:13:33 +05:30
|
|
|
bundle exec rails console -e production
|
2019-03-02 22:35:43 +05:30
|
|
|
```
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# run this in the Rails console
|
|
|
|
# replace <SLACK URL> with your actual Slack URL
|
|
|
|
result = Net::HTTP.get(URI('https://<SLACK URL>'));0
|
|
|
|
|
|
|
|
# replace <GITLAB URL> with your actual GitLab URL
|
|
|
|
result = Net::HTTP.get(URI('https://<GITLAB URL>'));0
|
|
|
|
```
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
If GitLab is not trusting HTTPS connections to itself, then you may
|
2019-03-02 22:35:43 +05:30
|
|
|
need to [add your certificate to GitLab's trusted certificates](https://docs.gitlab.com/omnibus/settings/ssl.html#install-custom-public-certificates).
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
If GitLab is not trusting connections to Slack, then the GitLab
|
|
|
|
OpenSSL trust store is incorrect. Some typical causes: overriding
|
|
|
|
the trust store with `gitlab_rails['env'] = {"SSL_CERT_FILE" => "/path/to/file.pem"}`,
|
2019-03-02 22:35:43 +05:30
|
|
|
or by accidentally modifying the default CA bundle `/opt/gitlab/embedded/ssl/certs/cacert.pem`.
|