Answer the question
In order to leave comments, you need to log in
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
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');
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question