在Gitlab中分支的Webhooks [英] Webhooks for branching in Gitlab

查看:733
本文介绍了在Gitlab中分支的Webhooks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当在Git/Gitlab中更新分支时,是否有办法触发Webhook?

Is there a way to have a Webhook fire whenever 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 coding phase - ex: a repository for development, a repository for testing, a repository for production.

问题是,一旦Master分支发生更改,我就需要采取措施.例如,如果开发存储库已更新,则将克隆"开发代码,生成一个.exe文件,然后将该文件放入开发"目录中以进行测试.

The thing is, I need for actions to take place once the Master branch changes. For example, if the Development repository is updated, the Development code is to be "cloned", a .exe file is generated and the file is then placed into a "Development" directory for testing purposes.

理想情况下,一旦开发顺利,就可以将代码提升"为测试".如果测试"顺利进行,则可以将代码提升为生产".

Ideally, once development goes well, you "promote" the code to "testing". If "testing" goes well, you then promote the code to "production".

问题在于无法在存储库之间提升"代码.唯一可用的是能够将较低的分支与较高的分支合并.

The problem is that there is no way to "promote" code between repositories. The only thing available is being able to merge a lower branch with a higher one.

我看到的所有示例都涉及开发分支,测试分支,而生产"分支实际上是存储库的主分支.

All of the examples I have seen refer to development branches, test branches and a "production" branch is actually the master branch of the repository.

好的-我可以接受;但是,在这种情况下,我将需要基于开发分支编译开发代码,基于测试分支编译测试代码,等等.

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

为此,Webhook需要启动,以便可以采取适当的措施来完成上述任务(因此才提出我的问题).

For this to take place, a Webhook needs to fire so that appropriate actions can be taken to do the tasks above (hence the reason for asking my question).

那么-再一次-当存储库中的特定〜分支更改时,如何使Webhook触发?

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

推荐答案

当存储库中的特定〜分支〜发生更改时,如何使Webhook触发?

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

看起来像问题1176

如果您查看发布的数据,您已经

If you look at the posted data, you have

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

Webhooks可以向脚本发送POST请求,并带有描述推送的有效负载.

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

您需要一个服务来监听该Webhook.

You need a service listening to that webhook though.

如果您使用Jenkins服务器,则可以 Jenkins GitLab插件分支过滤",以便您的Webhook指向.

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

这篇关于在Gitlab中分支的Webhooks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆