softdevteam / mattermost-github-integration

GitHub integration for Mattermost
Other
79 stars 50 forks source link

webhook not publishing in mattermost #1

Closed shaimona closed 8 years ago

shaimona commented 8 years ago

I am trying tin integrate this with GHE. I have set up webhook in GHE. I can see GHE sending payload over to integration server(10.1x.xx.xx) - - [28/Jan/2016 19:48:54] "POST / HTTP/1.1" 200 - ) seems like Integration server is not sending payload over to mattermost server. However I can manually send test messages to mattermost server using same incoming webhook.

ptersilie commented 8 years ago

I'm sorry to hear that. Does the server print any error messages? Also, what is GHE?

ptersilie commented 8 years ago

I assume GHE is Github Enterprise. I have no experience with that, but I am wondering if the JSON data GHE sends over to the server is different from normal Github.

shaimona commented 8 years ago

Lukas, Below is the payload GHE is sending User1 = userID

{ "zen": "Encourage flow.", "hook_id": 24, "hook": { "url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox/hooks/24", "ping_url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox/hooks/24/pings", "id": 24, "name": "web", "active": true, "events": [ "push" ], "config": { "url": "http://10.1xx.xx.xx:5000", "content_type": "json", "insecure_ssl": "0", "secret": "" }, "updated_at": "2016-01-28T19:12:00Z", "created_at": "2016-01-28T19:12:00Z" }, "organization": { "login": "infrastructure-sandbox", "id": 203, "url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox", "repos_url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox/repos", "events_url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox/events", "members_url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox/members{/member}", "public_members_url": "https://git.example.net/api/v3/orgs/infrastructure-sandbox/public_members{/member}", "avatar_url": "https://avatars.git.example.net/u/203?", "description": null }, "sender": { "login": "user1", "id": 61, "avatar_url": "https://avatars.git.example.net/u/61?", "gravatar_id": "", "url": "https://git.example.net/api/v3/users/user1", "html_url": "https://git.example.net/user1", "followers_url": "https://git.example.net/api/v3/users/user1/followers", "following_url": "https://git.example.net/api/v3/users/user1/following{/other_user}", "gists_url": "https://git.example.net/api/v3/users/user1/gists{/gist_id}", "starred_url": "https://git.example.net/api/v3/users/user1/starred{/owner}{/repo}", "subscriptions_url": "https://git.example.net/api/v3/users/user1/subscriptions", "organizations_url": "https://git.example.net/api/v3/users/user1/orgs", "repos_url": "https://git.example.net/api/v3/users/user1/repos", "events_url": "https://git.example.net/api/v3/users/user1/events{/privacy}", "received_events_url": "https://git.example.net/api/v3/users/user1/received_events", "type": "User", "site_admin": true, "ldap_dn": "CN=user1\, user1,OU=All Users,DC=ad,DC=example,DC=com" } }

ptersilie commented 8 years ago

Ah, this looks like the Github ping payload. This is not forwarded to the Mattermost server. So you might want to test the integration with a proper payload, e.g. issue comment, commit, PRs, etc.

Although come to think of it it might be sensible to forward the ping as well so people can test if the integration is working before real events are sent.

shaimona commented 8 years ago

Great.. it is working as expected. One more quick question. We have multiple Github organizations and repos belonging to different groups who want to send notification to their mattermost channels. How can I modify config.py to send notification to different channels based on org/repos? Please let me know.

jaheba commented 8 years ago

Currently there is no way to specify this in the config. You could setup multiple servers (which does the job but is cumbersome) or extend server.py so that it sends the message to a different channel depending on the repository in which the change happened.

Maybe I have some time on the weekend to look into this further.

ptersilie commented 8 years ago

I'm already working on this. :)

I am extending the config.py to specify different webhook urls depending on the organisation name or repository name. I'm currently testing the implementation.

ptersilie commented 8 years ago

@shaimona I pushed an update that allows to specify different hooks depending on the payloads repository name or organisation name (see Readme.md and config.template).

Give it a go and let me know if you run into any problems.