Custom hook after ingest with gitlab

I am trying to set up a custom post receive using gitlab

I am following their documentation here

I have a post-receive executable in the custom_hooks folder with the following code:

 !/bin/bash
 echo "post-receive firing | wall
 git pull

      

If I run this file with

 ./post-receive

      

It works great. It doesn't seem to fire at all when pushing to the gitlab repository.

This is the first time I've ever tried any type of webhooks, so I'm a little lost.

a) I have the above script on my remote web server inside the .git / custom_hooks folder, is this correct?

b) Do I need to do anything in the repo?

c) The documentation states that I must set the file permissions to be owned by the git user. I don't have a git user on the web server ... all other git related files are owned by my user or root.

So, assuming I am doing something completely wrong here, can someone please spare me my misery and suggest a sane way to automatically push to the web server whenever I push to gitlab from my local machine. I feel like I've spent some time figuring out a way to do this and the solutions seem like complete overkill (cronjob runs every few seconds ...) or, like above, don't work. Or at least I cannot get them to work.

Of course, this is an easy task ...

+3


source to share


2 answers


in the file to be owned by the git user. I don't have a git user on the web server ... all other git related files are owned by my user or root.

This is because the oyur web server is a client of the GitLab server.
the documentation you link to is for configuring the GitLab server (adding a post-ingest hook to the GitLab repository). Hence user ' git

', which is the default GitLab server
.

But if you click on gitlab.com you are not directly adding the hook.



You will need to declare a webhook , which will then send back a JSON message that you can listen on to trigger another action .

If you're the only one who pushed, you can just push multiple repos . It has no hooks, client or server.
But this will be a local setting, only valid for your local cloned repo.

+3


source


Follow next steps



require 'net / http' require "uri" uri = URI.parse ("YOUR_URL") response = Net :: HTTP.get_response (uri)

Hope this helps you

+1


source







All Articles