简体   繁体   English

如何在 GitLab 中配置服务器端 custom_hooks?

[英]How can I configure Server-Side custom_hooks in GitLab?

I've tried below approach and it works fine.我试过下面的方法,它工作正常。 However, it just commits and pushes from my local to git then it will push to the remote server.但是,它只是从我的本地提交并推送到 git,然后它将推送到远程服务器。

git remote add origin https://code.company.com/autodeployment/fiver.git
git remote set-url --add --push origin https://code.company.com/autodeployment/fiver.git
git remote set-url --add --push origin fiver@server01.company.com:/var/fiver/fiver.git

I wanted to commit and push from my local to Git and Git should have a custom_hook where the remote server will auto-fetch or the Git will auto push to the remote server.我想从本地提交并推送到 Git,并且 Git 应该有一个 custom_hook,远程服务器将在其中自动获取或 Git 将自动推送到远程服务器。

Don't bother with hooks for this.不要为此费心使用钩子。 Simply define a push mirror.只需定义一个推送镜像。 This is available in CE version if you wonder (only pull mirrors need the EE version).如果您想知道,这在 CE 版本中可用(只有 pull mirrors 需要 EE 版本)。

Go to your repo > settings > repository > mirroring settings and just follow the guide.转到您的存储库 > 设置 > 存储库 > 镜像设置,然后按照指南进行操作。

The only very small drawback I have experienced so far is that there is a 5 minutes limit between pushes.到目前为止,我遇到的唯一非常小的缺点是两次推送之间有 5 分钟的限制。 But it is rarely a blocker in real life as you can still push manually to all your remotes if you really need to.但它在现实生活中很少成为阻碍,因为如果您真的需要,您仍然可以手动推送到所有遥控器。

Reference: https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html参考: https : //docs.gitlab.com/ee/user/project/repository/repository_mirroring.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM