用于在 Gitlab 中进行分支的 Webhook [英] Webhooks for branching in Gitlab

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

问题描述

有没有办法在 Git/Gitlab 中更新分支时触发 Webhook?

我正在尝试设置开发工作流程.最初的想法是为每个编码阶段建立一个存储库 - 例如:一个用于开发的存储库、一个用于测试的存储库、一个用于生产的存储库.

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

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

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

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

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

为此,需要触发一个 Webhook,以便采取适当的措施来完成上述任务(这也是我提出问题的原因).

那么 - 再一次 - 当存储库中的特定 ~branch~ 发生更改时,如何让 Webhook 触发?

解决方案

当存储库中的特定 ~branch~ 发生更改时,如何触发 Webhook?

这看起来像 issues 1176

<块引用>

如果你查看发布的数据,你有

:ref =>裁判/负责人/大师",

<块引用>

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

你需要一个服务来监听那个 webhook.

如果你使用 Jenkins 服务器,你可以有 一个 Jenkins 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.

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.

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).

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

解决方案

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.

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

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