Slack Notification is not working in 7.4.2
Created by: amree
Summary
Slack notification is not working in the latest version (7.4.2). It used to work in 7.2.1. I'm not sure about other versions. The main causes would be the old version of slack-notifer
gem which was hard coded with the wrong url:
https://github.com/stevenosloan/slack-notifier/blob/0.3.2/lib/slack-notifier.rb#L44
URI.parse "https://#{team}.slack.com/services/hooks/#{hook_name}?token=#{token}"
It should be in this form:
https://hooks.slack.com/services/#{token}
Related commit: https://github.com/stevenosloan/slack-notifier/commit/04006c8d2aeba4bf9086ff2524bae88919a4d424
That's why it's throwing 404 error.
Steps to reproduce
The fastest way would be by testing slack-notifer
gem directly since GitLab uses it to send notification to Slack.
-
Get your Incoming Webhooks URL. For e.g: https://hooks.slack.com/services/sadfsad/asdfasd/asdfsadfasdf
-
Open up rails console and try sending a simple ping
$ gitlab-rails console
irb> notifier = Slack::Notifier.new "hooks", "sadfsad/asdfasd/asdfsadfasdf" irb> notifer.ping 'hello'
Net::HTTPNotFound 404 Not Found readbody=true
Expected behaviour
A message will be sent to Slack successfully
Observed behaviour
Getting 404 error
Relevant logs and/or screenshots
Doesn't appear when doing gitlab-ctl tail
Output of checks
GitLab Application Check:
$ gitlab-rake gitlab:check
Checking Environment ...
Git configured for git user? ... yes
Checking Environment ... Finished
Checking GitLab Shell ...
GitLab Shell version >= 2.0.1 ? ... OK (2.0.1)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
Satellites access is drwxr-x---? ... yes
hooks directories in repos are links: ...
repositories ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
/var/opt/gitlab/git-data/repositories: OK
/var/opt/gitlab/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 2.8.2
Send ping to redis server: PONG
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
GitLab version: GitLab 7.4.2 477743a1
Setup:
$ gitlab-rake gitlab:env:info
System information
System: Debian 7.6
Current User: git
Using RVM: no
Ruby Version: 2.1.2p95
Gem Version: 2.2.1
Bundler Version:1.5.3
Rake Version: 10.3.2
Sidekiq Version:2.17.0
GitLab information
Version: 7.4.2
Revision: 477743a
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: http://gitlab.orgnet
HTTP Clone URL: http://gitlab.orgnet/some-project.git
SSH Clone URL: [email protected]:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 2.0.1
Repositories: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
Possible fixes
I think GitLab have to upgrade slack-notifier
gem to the latest version and change the code accordingly.