mattermost / mattermost-plugin-gitlab

GitLab plugin for Mattermost
Apache License 2.0
139 stars 84 forks source link

GitLab Webhook not showing up in Mattermost #121

Closed hardysim closed 4 months ago

hardysim commented 4 years ago

I've followed the instructions in the readme here, set up the plugin in mattermost, connected my user etc. I can see the gitlab-bar with the counters on mattermost correctly but it seems that no webhooks are showing up in mattermost when sent by gitlab.

I've created a webhook in a gitlab-project using https://mattermost.my.domain/plugins/com.github.manland.mattermost-plugin-gitlab/webhook and the secret created in the plugin settings page in mattermost. When testing, I get a green 200 OK result but I don't get any message in mattermost.

Where should the show up? In the private-messages-channel with the GitLab Plugin bot?

PS: Sending webhooks from gitlab to mattermost using the (now outdated?) Mattermost notifications project service works (but here I need to create an incoming webhook integration in mattermost which forwards the webhooks to a specific mattermost channel).

levb commented 4 years ago

@hardysim I don't use the plugin, but I believe that you need to /gitlab subscribe to get the notifications posted into a channel. Did you do that?

hardysim commented 4 years ago

Hmm, so I need to set up the webhook for the project and each user needs to /gitlab subscribe?


When trying to subscribe, I receive an error. Using /gitlab subscribe android (android is a group on my GitLab server) results in:

Unable to retreive informations for android/`

The same happens for /gitlab subscribe android/project1 etc.. Any ideas?

kop commented 4 years ago

I also see some strange behaviour related to webhooks and I may have found the reason, but need an extra pair of eyes here, maybe I'm missing something.

@manland, please correct me if I'm wrong,

In https://github.com/mattermost/mattermost-plugin-gitlab/blob/master/server/plugin.go#L152

p.API.KVSet(userID + GITLAB_IDUSERNAME_KEY, []byte(gitlabUsername) // userID is Mattermost user ID

But in https://github.com/mattermost/mattermost-plugin-gitlab/blob/master/server/plugin.go#L167

p.API.KVGet(gitlabUserID + GITLAB_IDUSERNAME_KEY) // gitlabUserID is GitLab user ID

This mismatch makes GITLAB_IDUSERNAME_KEY useless and ToUsers will never be filled by webhooks.

hardysim commented 4 years ago

Just to make sure: How do I subscribe to projects or groups? Is /gitlab subscribe android/project1 correct or do I need to do more? Maybe I missed something during the setup?

kop commented 4 years ago

@hardysim, If webhook(s) are already configured, then yes, /gitlab subscribe android/project1 is all you need. Type /gitlab help for more commands.

hardysim commented 4 years ago

I've just activated "Enable Private Repositories" and now it's working. I can subscribe to my repo (it was set to private in gitlab so it's my fault).


But it seems like not all events are received. When sending all the test-events via gitlab (on the "edit webhook page") only a few are received in mattermost.

At gitlab, I see the "Recent Deliveries" are all green (200) but one (Confidential Issue Hook) which seems OK so far but only the following are received:

I checked all the triggers on the gitlab-webhook and added all the features with the subscribe command in mattermost:

/gitlab subscribe android/project1 issues,merges,pushes,issue_comments,merge_request_comments,pipeline,tag,pull_reviews

Is this a limit of the plugin? Or is there still something wrong?

manland commented 4 years ago

@kop wouhaou good catch! I create a dedicated issue now! Thank you very much ;)

@hardysim it's definitively not normal. I have tested (manually and with unit test) all events. But I haven't tested trigger them with the UI in settings. Maybe a field is empty or something like that... Can you look at logs please?

hardysim commented 4 years ago

Hmm, where do I find the logs? When I just "use" gitlab normally and check, which actions trigger messages in mattermost, it seems like the same actions are missing.

E.g. I create a new issue in gitlab but there's no message in mattermost. When I finish its MR and the pipeline is running, I get a message in mattermost (but still, only the pipeline for the merge-into-master, not the on-every-commit pipeline [which is fine for me]).

hardysim commented 4 years ago

I'v tested subscription by using gitlab (not via the tests on the webhook-details-page). When subscribing in mattermost, there are the following options:

grisuthedragon commented 4 years ago

I set up the plugin today and the same problem appears. I did every as described in the readme for an internally visible project and nothing gets recieved in the channel, where I subscribed the project. The test of the webhook replies with HTTP 200 sucht that it is at least recieved by the plugin properly.

Is there any advance on this problem? Because we do not want to use the incomming webhook with the gitlab notifications since we need some projects in many channels.

I am using Mattermost 5.12 with the shippend Gitlab-Plugin ( Version 1.1 )

cpaulik commented 4 years ago

We are having problems getting private notifications. Some do work like direct @ mentions. But a comment on my issue that does not specifically mention me does not show up in mattermost.

Is this related or should I open a separate issue?

grisuthedragon commented 4 years ago

I figured out that the plugin actually works, but not with the Webhook-Test button in gitlab. After creating the webhook I clicked on the test button and checked several events and nothing happend. I created and issue and I got the message in mattermost. So it should be fixed, that the tests from gitlab work as well.

raghavaggarwal2308 commented 4 months ago

@hardysim Are you still facing the issue or we can close it?

hardysim commented 4 months ago

Uh sorry, I'm no longer using either GitLab nor Mattermost so I don't know if its fixed in the mean time. Let's close this, yes.