Open Thedude7054 opened 5 years ago
I've used this on my personal computer to connect to both a remote private machine running GitLab server and a GitLab.com free account, and both worked, so the answer should be 'yes' (but it's been more than a year since I've looked at this).
Can you give me more information about what you're doing and what specifically didn't work?
I attempted to run on a completely open-to-the-world Google Cloud Compute Engine instance, with the following config file (confidential creds removed of course) `{
"bot": {
"name": "GitLab Webhook Bot",
"id": "(removed)",
"token": "(removed)",
"prefix": ">",
"debug_channel_id": "546847271803813888",
"master_user_id": "(removed)"
},
"webhook": {
"name": "WebHook",
"icon_url": "https://cdn.discordapp.com/avatars/(removed)/a_d34e1a568b75bad37697cda730397f37.gif?size=128",
"id": "(removed)",
"token": "(removed)",
"server": {
"address": "localhost",
"port": "9000"
},
"gitlab_url": "(private instance)",
"gitlab_access_token": "(removed)"
}
}` The webhook the bot sends on start shows up in the channel I've set, but then crashes
Does the Debug channel give you any error messages?
When it crashes, is it immediately after the start message, or is it triggered by some GitLab event?
If the answer to 2 is 'immediately after the start message' the most likely reason is an outdated Discord Bot API. I'll try looking into this today to get it updated.
Sometime this week I'll try working on the refactor again, which will separate this project into an Express server that relays events directly to a Discord Webhook, and an optional bot for other purposes.
(If answer to 2 is something else) If you're using PM2, what appears in the logs for this process? If not, can you try running and send the output to a file so we can see what's going on?
I checked the latest version of Discord.JS (11.4) and there is nothing in the bot code that got deprecated, so I will need to know what error you are getting in your logs.
If you are using PM2 you can see the logs with pm2 log
or find them at /home/user/.pm2/logs
(assuming your machine is running Linux)
Immediately after the start message, no GitHub event trigger ever happens, with no debug channel message. The error it returns is something to the effect of address not available when I use the server’s own IP. I have tried using localhost as the bot address in the config file, and it starts without error, but it then receives no messages from GitLab.
Ah, so this is more to do with what internal address is available on your Google Cloud Compute Engine.
Try using 0.0.0.0
as your address, and see if that works.
For more information about it, you should check the Google Cloud Compute Engine docs for Node.js server apps.
Closing this issue due to inactivity. If the problem persists, you may re-open this issue.
Apologies for my late reply. No luck on setting to 0.0.0.0 on the bot. Gitlab still times out.
In GitLab's configuration settings, did you include the port number in the URL field?
For example, http://example.com:9000
where http://example.com
is your public IP and not a 192 number.
Yes I did.
Are you still getting any error message? Or is it just that GitLab fails to send a test event?
Are you running any other servers on open ports? If so, do those load correctly from an external network?
I haven't used Google Cloud Compute Engine so I don't know much about configuring it. You might be better off browsing StackOverflow for "connecting to a server running on a Google Cloud Compute Engine." For example, this one that is resolved by ensuring the external IP is static and not ephemeral.
Gitlab says that it's request has timed out. When testing I've been running the bot on it's own dedicated compute server, with nothing but the bot running. When I try configuring the webhook, I copy the IP straight from the Google Cloud Console. Later today I'll double check the external IP is static.
Update: Now working on GitLab. New issue:
Hmm... this repo is meant to be used with webhooks (events for individual projects) and not for system hooks (events for the entire instance). GitLab's System Hooks API has a different set of event types and HTTP headers than the Webhooks API.
I could add another case for detecting the object type when the X-Gitlab-Event value is a general 'System Hook' and not the standard 'Push Hook' or 'Issue Hook', but I feel this would be fundamentally wrong.
Do you intend to send Discord updates for things like "Project created", "User added", and push events for every single project on your instance regardless of whose project it is?
If not, I think you may have configured the webhook through Admin/Hooks by mistake, instead of through your project's Settings/Integrations.
Ideally I just want push notifications for all repos
But this is tricky because if I want data from each repo, I'll need to manually add it to each and every repo.
Each repo is supposed to be configured individually. Otherwise you risk exposing push data from repos whose owners have not opted to share their push data.
If you have a lot of repos to manage (over 20) and your instance is being used only by you, I might be willing to support System Hooks but it won't be added until the next version.
Is there any way to run this on a machine that is not the target Gitlab server? I can't get anything like it to work.