gitlab-shell中的“post-receive”挂钩是否仍可用于自定义挂钩?

时间:2013-04-27 20:27:10

标签: git gitlab git-post-receive post-commit-hook chiliproject

根据gitlab-shell post-receive挂钩的内容,它已被弃用。

#!/usr/bin/env ruby

# This file was placed here by GitLab.
# IT IS DEPRECATED NOW.
# All GitLab logic handled by update hook

但是只针对Gitlab特定逻辑还是一般? Imho我仍然可以使用它,例如我的chiliproject post-receive钩子更新了我的存储库。不幸的是,我找不到这方面的任何具体内容,主要是因为gitolite<> gitlab v5中的gitlab-shell转换。我希望有人可以对此有所了解......

[编辑]

v1.7.1中gitlab-shell的post-receive挂钩was removed。因此,正确的方法是创建一个Web钩子,仔细修改更新钩子或更密切地观察gitlab-shell的开发,直到实现自定义钩子支持。 ; - )

1 个答案:

答案 0 :(得分:4)

2014年更新:

Ciro Santilli指出in the comments和“Custom post-receive file using GitLab”现在(GitLab不再使用gitolite)了解 setup custom hooks (GitLab 7.5.0 +,2014年11月)。

  
      
  1. 选择需要自定义git hook的项目。
  2.   
  3. 在GitLab服务器上,导航到项目的存储库目录   对于手动安装,路径通常为/home/git/repositories/<group>/<project>.git   对于Omnibus安装,路径通常为/var/opt/gitlab/git-data/repositories/<group>/<project>.git
  4.   
  5. 在此位置创建名为custom_hooks
  6. 的新目录   
  7. custom_hooks目录中,创建一个名称与钩子类型匹配的文件   对于pre-receive挂钩,文件名应为pre-receive,不带扩展名。
  8.   
  9. 使钩子文件可执行,并确保它由git拥有。
  10.   
  11. 编写代码以使git钩子函数按预期方式运行。钩子可以是任何语言。确保顶部的“shebang”正确反映语言类型   例如,如果脚本在Ruby中,则shebang可能是#!/usr/bin/env ruby
  12.   

原始答案(2013年4月)

这是不使用gitolite并使用Gi​​tLab5.x将其替换为gitlab-shell的直接后果。

这就是为什么你有gitlab-shell Issue 14关于允许自定义更新挂钩的原因。

现在,你会为Gitlab服务器上的每个repos添加注册钩子,这不是很方便。