Webhooks for Forking in Gitlab

Is there a way to have a Webhook fire when a branch is updated in Git / Gitlab?

I am trying to set up a development workflow. The original idea was to have a repository for each phase of coding - ex: repository for development, repository for testing, repository for production.

The point is that I need the actions to happen after the master branch is changed. For example, if the development repository is updated, the development code must be "cloned", an .exe file is generated, and then the file is placed in the Development directory for testing purposes.

Ideally, when development is going well, you "push" the code towards "testing". If "testing" goes well, you then push the code to "production".

The problem is that there is no way to "push" code between repositories. The only thing available is merging the lower branch with the higher one.

All the examples I've seen are for development branches, test branches, and the "production" branch - actually the main branch of the repository.

OK - I can accept that; however, in this case, I would need to compile development code based on development branch, test code based on test branch, etc.

For this to happen, Webhook needs to be started so that appropriate actions can be taken to complete the above tasks (hence the reason for my question).

So - once again - how can you get the Webhook to fire when a particular branch ~ changes in the repository?

+4


source to share


3 answers


how can I get Webhook to fire when a particular ~ branch ~ changes in the repository?

It looks like problems 1176

If you look at the published data, you have

:ref => "refs/heads/master",

      



Webhooks is sending a POST request to a script with a payload describing push.

You need a service that this webhook is listening on.

If you are using Jenkins server, you can connect Jenkins GitLab plugin to branch filtering for your web host.

+2


source


Build trigger -> Build when changes are pushed to GitLab -> Advanced -> Allowed Branches -> Filter Branches by Name -> In the include box, enter the name of the branch for which you want to run the build job (note, write the branch name without * /)



I noticed that even after you enter the correct branch name, it still displays the message "The following templates do not match any branch in the original repository:" You can ignore this and test your webhook. This worked for me.

0


source


maybe a little late, but for those still looking for a solution here you go. Master 2 (production) and development of 1 or 2 web server (s) does not matter. In gitlab, when integrating, 2 webhook (s) are installed with a filter for each branch, one goes to the prod url and the other to the dev url. I am using a script at a specific address (dir) at the end of the server url to checkout into the desired branch and pull the changes. so the url will look something like this: https://devurl.example.com/dir/deployment.php end of the script I am calling like "master or development git pull origin master"

Simple but works great. The hoop that helps

0


source







All Articles