我使用GitLab社区版8.2,并希望添加后提交挂钩。
我用权限创build了文件path_to_project.git / custom_hooks / post-commit
$ ls -l1 custom_hooks/post-commit -rwxr-xr-x 1 git git 45 Dec 14 21:31 custom_hooks/post-commit
和内容
#!/bin/bash echo "test custom" > /tmp/hook
如下所述: http : //doc.gitlab.com/ce/hooks/custom_hooks.html
但它不起作用(通过Web界面进行检查)。 我也尝试了'正常的'git钩子放置(project.git / hooks / post-commit),但它也不起作用。
post-commit是一个客户端挂钩,你不能在服务器上实现它。
根据Gitlab文档: http ://doc.gitlab.com/ce/hooks/custom_hooks.html,可以在服务器上实现服务器端定制挂钩( pre-receive , post-receive and update )。
服务器端git钩子的例子包括预接收,后接收和更新。 有关每个钩子types的更多信息,请参阅Git SCM Server-Side Hooks 。
如果你想定制一个客户端钩子,你将需要改变原来的钩子代码,或者把你的自定义脚本放在.git/hooks下的客户端。 阅读更多: 什么是Git钩子?
这里是关于自定义钩子: 自定义Git – Git钩子