如何在 GitLab 的服务器端添加预接收挂钩? [英] how to add the pre-receive hook in server side in GitLab?

查看:17
本文介绍了如何在 GitLab 的服务器端添加预接收挂钩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试限制在我们的 gitlab 中提交的二进制文件(EXE、DLL、PDF).所以我需要添加钩子以在全局范围内限制它.我怎样才能做到这一点?Pre-receive hook 适合这个吗?

I am trying to restrict the binary file (EXE, DLL, PDF) committing in our gitlab. So I need to add the hook to restrict it in globally. How can I do this? Is Pre-receive hook is suitable for this?

这个地方加钩子对吗?

/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive

/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive

任何帮助表示赞赏!

推荐答案

你可以安装一个侧宽的钩子,但它没有很好的文档记录.Gitlab 目前正在集成 gitlab-shellgitaly.所以提供指令是一个移动的目标,但它们在 12.3.5 版本中有效.

You can install a side-wide hook, but it is not very well documented. Gitlab is currently integrating gitlab-shell and gitaly. So providing instructions is a bit of a moving target, but they are valid as of the release of 12.3.5.

gitlab-shell/hooks/* 中的脚本扫描当前存储库和站点范围的目录.但是,在全新安装时不会创建站点范围的目录,您需要自己创建它们.

The scripts in gitlab-shell/hooks/* scan the current repository and site wide directories. However, the site wide directories will not be created at a clean install and you need to create them yourself.

mkdir -p <XXX>/gitlab-shell/hooks/pre-receive.d       # or update.d or post-receive.d
chown git:git <XXX>/gitlab-shell/hooks/pre-receive.d

# link or copy your script of course it needs to be executable by the Gitlab user
ln -s /usr/bin/my-hook <XXX>/gitlab-shell/hooks/pre-receive.d/my-hook

这篇关于如何在 GitLab 的服务器端添加预接收挂钩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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