G
G
gerrrper2014-09-30 16:34:22
git
gerrrper, 2014-09-30 16:34:22

How to create a hook in gitlab to react to a commit ?

As I understand it, I need a web-hook. But the panel only has a service-hook that prompts me to add a URL.
At first I thought that gitlab would send data to this URL - but it doesn't.
I need to keep track of commits, and respond to each one. How can I do it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Romanov, 2014-09-30
@gerrrper

Well, on the server where you have the site, make a script that runs the git pull command. And add the url to this script. The hook service simply guarantees that after the commit, a request will be sent to the repository at this url. And you do it yourself.
Here is an example. It's primitive. You can't do that. It's not safe. Just to explain the idea. In the service hooks, put the url
mysite/git.php
On the site, create the git.php file

<?php
exec('git pull');

Something like this.

S
Sergei Borisov, 2014-10-01
@risik

I'll add a little to @Serhioromano
's answer. I can assume that you are using some kind of CI / CD server for deployment. This server should be able to run a job on an external event. This external event is generated, for example, by accessing a specific URL. Perhaps this url even needs to pass some kind of authentication key that is generated by this CI server. You now have a URL that you need to flick to complete the build.
This is the URL you specify in GitLab.

A
adisos, 2014-10-05
@adisos

https://developer.github.com/webhooks/securing/ - this is on sinatra
https://gist.github.com/adisos/becda706373ad3d60da7 - here is my nodejs solution (using restify)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question