Webhooks for branching in Gitlab

时光毁灭记忆、已成空白 提交于 2019-12-04 07:38:18

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

That looks like issues 1176

If you look at the posted data, you have

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

Webhooks works sending a POST request to a script, with a payload describing the push.

You need a service listening to that webhook though.

If you use a Jenkins server, you can have a Jenkins GitLab plugin "branch filtering" for your webhook to point to.

Build trigger --> Build when a change is pushed to GitLab. --> Advanced --> Allowed branches --> Filter branches by name --> In the include box write the branch name for which you want to trigger the build job (Please note, write the branch name without the */ )

I have noticed that even after you type in the correct branch name it still throws the message "Following patterns don't match any branch in source repository: " You can ignore this and test your webhook. It worked for me.

maybe little late but for those still looking for a solution here you go. 2 branches master (production) and development 1 or 2 web server(s) , doesn't matter. In gitlab under integration set 2 webhook(s) with filter for each branch , one goes to prod URL and other to dev URL. I use script at specific address (dir) o those server url end to checkout to the right branch and pull changes. thus url will be something like this https://devurl.example.com/dir/deployment.php end in script i am calling this command e.g. 'git pull origin master or development'

Simple but works perfectly. Hoop that helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!