我想限制在我们的gitlab中提交二进制文件(EXE,DLL,PDF)。因此,我需要添加挂钩以在全局范围内进行限制。我该如何做?Pre-receive hook是否适合此操作?
这里是添加挂钩的正确位置吗?
/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive
非常感谢任何帮助!
我想限制在我们的gitlab中提交二进制文件(EXE,DLL,PDF)。因此,我需要添加挂钩以在全局范围内进行限制。我该如何做?Pre-receive hook是否适合此操作?
这里是添加挂钩的正确位置吗?
/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive
非常感谢任何帮助!
您可以安装全站钩子,但文档不是很完善。Gitlab目前正在集成gitlab-shell
和gitaly
。因此,提供说明有点像移动目标,但它们在12.3.5版本发布时是有效的。
gitlab-shell/hooks/*
中的脚本会扫描当前存储库和全站目录。但是,在干净的安装中不会创建全站目录,您需要自己创建。
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添加钩子" 查看详细步骤,并涉及创建一个专用的 repo.git/custom_hooks
子文件夹。
但这是针对每个存储库而不是所有存储库。
您需要为组中的每个存储库添加该脚本。
您在普通 repo.git/hooks
文件夹中看到的 pre-receive
脚本实际上是指向 gitlab-shell hook
文件夹的符号链接,并且 GitLab 使用它来管理访问权限。