Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GitLab integration webhook payload parser script #2367

Closed
pescobar opened this issue Feb 28, 2016 · 20 comments
Closed

Create GitLab integration webhook payload parser script #2367

pescobar opened this issue Feb 28, 2016 · 20 comments
Assignees
Milestone

Comments

@pescobar
Copy link

Hi,

I am running rocket chat 0.19.0 using the official docker image.

I have configured an incoming webhook integration in rocket chat to get notifications from my gitlab instance. The weird thing is that when I configure slack service in gitlab it works fine but when I configure a webhook in gitlab using the same url it doesn't work. The bot prints an empty message in the channel without the push details.

I would like to use webhooks in gitlab instead of the slack service because I would like to enable rocket chat notifications for all my gitlab projects and using webhooks I could try this https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/web_hooks.md but the slack service has to be configured for each repository.

do you have any clue what could be the problem? I am using gitlab 8.4.4

@pescobar
Copy link
Author

In case it helps, I am getting this in the rocket.chat log but the message that hubot prints in the channel is empty

Post integration
@urlParams { integrationId: 'SC9tJosBkBhzg5RYP',
  userId: 'bSqeAfRmh9zfWhLSp',
  token: 'kP60cdVwVN3xQtOkHxVH2XvfhsaZPBBU4z2+iK2ewNs=' }
@bodyParams { object_kind: 'push',
  before: '6c98263e628df226d9b810880678a4ed77ae73d8',
  after: 'cfe728852043e29488a4802a825215dca3d5755b',
  ref: 'refs/heads/master',
  checkout_sha: 'cfe728852043e29488a4802a825215dca3d5755b',
  message: null,
  user_id: 1,
  user_name: 'pescobar',
  user_email: '[email protected]',
  project_id: 22,
  repository:
   { name: 'misc_scripts',
     url: '[email protected]:gilab_group/misc_scripts.git',
     description: 'all miscellianous scripts for administration',
     homepage: 'https://gitlab-domain.com/gilab_group/misc_scripts',
     git_http_url: 'https://gitlab-domain.com/gilab_group/misc_scripts.git',
     git_ssh_url: '[email protected]:gilab_group/misc_scripts.git',
     visibility_level: 0 },
  commits:
   [ { id: 'cfe728852043e29488a4802a825215dca3d5755b',
       message: 'test 3\n',
       timestamp: '2016-02-28T23:50:27+01:00',
       url: 'https://gitlab-domain.com/gilab_group/misc_scripts/commit/cfe728852043e29488a4802a825215dca3d5755b',
       author: [Object],
       added: [],
       modified: [Object],
       removed: [] },
     { id: '9806ab64a11470a3e04095f8e657c81640cc090f',
       message: 'test2\n',
       timestamp: '2016-02-28T23:16:39+01:00',
       url: 'https://gitlab-domain.com/gilab_group/misc_scripts/commit/9806ab64a11470a3e04095f8e657c81640cc090f',
       author: [Object],
       added: [],
       modified: [Object],
       removed: [] },
     { id: '6c98263e628df226d9b810880678a4ed77ae73d8',
       message: 'test\n',
       timestamp: '2016-02-28T23:13:55+01:00',
       url: 'https://gitlab-domain.com/gilab_group/misc_scripts/commit/6c98263e628df226d9b810880678a4ed77ae73d8',
       author: [Object],
       added: [],
       modified: [Object],
       removed: [] } ],
  total_commits_count: 3 }

@pescobar
Copy link
Author

pescobar commented Mar 3, 2016

I have upgraded to latest release 0.20.0 and I still have the same problem.

is anyone using gitlab webhooks with rocket chat?

@ma-karai
Copy link

ma-karai commented Mar 3, 2016

I have a similar issue where the webhook post
@bodyParams { update_id: 1337, message: { message_id: 1337, from: { id: 123456789, first_name: 'bott0r' }, chat: { id: 123456789, first_name: 'Kai', type: 'private' }, date: 1456911431, text: 'Hi how are you' } }
does not arrive at all, only an empty message just appears, i suppose it has something to do with the nested format.

@engelgabriel
Copy link
Member

Depends on #2426

@pescobar
Copy link
Author

pescobar commented Mar 4, 2016

thanks for looking into this @engelgabriel

@engelgabriel
Copy link
Member

@pescobar
Copy link
Author

pescobar commented Mar 9, 2016

is there any script for gitlab?

@engelgabriel
Copy link
Member

Working on it, want to help?

@pescobar
Copy link
Author

pescobar commented Mar 9, 2016

I can do beta testing in my gitlab instance if required. I have no experience with JS

@engelgabriel engelgabriel modified the milestones: GitLab, 0.22.0 Mar 14, 2016
@engelgabriel engelgabriel changed the title gitlab webhook configuration issue Create GitLab integration web-hook payload parcer script Mar 14, 2016
@engelgabriel engelgabriel changed the title Create GitLab integration web-hook payload parcer script Create GitLab integration webhook payload parcer script Mar 14, 2016
@engelgabriel engelgabriel changed the title Create GitLab integration webhook payload parcer script Create GitLab integration webhook payload parser script Mar 14, 2016
@sandish2222
Copy link

I got the same issue. Rocket chat showed empty message when gitlab pushed issue/comment through web hook.

i tried to write srcipts like https://github.com/RocketChat/Rocket.Chat/wiki/WebHook-Scripting---GitHub, but it doesnt work. Even the script is simple as below, it also doesnt work.

class Script {
  process_incoming_request({ request }) {
    return {
      text: "hello world"
   };
  }
}

i got the error below when i write script for incoming webhook,

I20160316-07:25:56.956(0) rocketchat_integrations api.coffee:61 Integrations ? Incoming WebHook.error [Error evaluating Script:] 
I20160316-07:25:56.959(0) rocketchat_integrations api.coffee:62 Integrations ? Incoming WebHook.error   result = (function() {   class Script {     process_incoming_request({ request }) {       return {         text: "hello world"      };     }   }   }()); 
I20160316-07:25:56.962(0) rocketchat_integrations api.coffee:63 Integrations ? Incoming WebHook.error  [Stack:] 
I20160316-07:25:56.968(0) rocketchat_integrations api.coffee:64 Integrations ? Incoming WebHook.error   
SyntaxError: Unexpected reserved word       
at new Script (vm.js:32:12)       
at Function.Script.createScript (vm.js:48:10)       
at Object.Api.addRoute.post [as action] (packages/rocketchat_integrations/server/api/api.coffee:56:19)       
at Route.Route._callEndpoint (packages/nimble_restivus/packages/nimble_restivus.js:318:1)       
at packages/nimble_restivus/packages/nimble_restivus.js:209:1       
at packages/simple_json-routes/packages/simple_json-routes.js:53:1

@manuelbachl
Copy link

could help, too

@scovl
Copy link

scovl commented Apr 27, 2016

One way improvised by a parser, would be to use any RSS reader application (example, the newsbeuter), pick up one or more RSS each gitlab project (preferably master branch), make a DIFF between RSS reader and the downloaded file (to check for update , commits etc...), and generate an output of with Curl for the rocket. chat. It's a bad idea?

@engelgabriel
Copy link
Member

@rodrigok can you help here?

@rodrigok
Copy link
Member

@sandish2222 are you editing and saving the script via the admin page?

@sandish2222
Copy link

@rodrigok i solved this issue. Just treat rocket chat as slack for gitlab instead of using webhook script.

it works well.

@scovl
Copy link

scovl commented Apr 28, 2016

@sandish2222 can you explain how you did it?

@toupeira
Copy link

@lobocode figured it out:

  1. on Gitlab, go to "Services" instead of "Hooks"
  2. select Slack
  3. enter the details (hook URL) as before, check "Active" and leave "Username" and "Channel" empty (not sure if they have an effect since we also have to specify it in the Rocket.Chat integration settings)

@teamsoo
Copy link

teamsoo commented Aug 14, 2016

@toupeira your solution will work on a single project not for every project in a group. If you go to group page you will see that there is only Webhooks option available, no Services option.

@toupeira
Copy link

@teamsoo thanks for pointing that out, I didn't realize Gitlab supports webhooks on groups :)

@engelgabriel
Copy link
Member

@engelgabriel engelgabriel modified the milestones: 0.51.0, GitLab Jan 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants