Ano*_*ous 15 git continuous-integration gitlab
我在CentOs上设置了一个新的Gitlab,/opt/gitlab-6.9.2-0/apps/gitlab/并在持续交付组下创建了一个新的存储库.完整的路径是/opt/gitlab-6.9.2-0/apps/gitlab/gitlab-satellites/continuous-delivery/cd-test
.此路径下只有一个文件是README.txt.
我试图实现的是当有人将更改推送到服务器时创建一个新文件.以下是我在服务器上所做的事情:
post-update和update文件.git/hooks/' each file creates a new file using当我将更改从本地推送到服务器时,没有创建文件.所以,我想知道我要做些什么来解决这个问题.
更新1
我添加post-receive并post-update到repositories路径VonC建议
[root@git-cd hooks]# pwd
/opt/gitlab-6.9.2-0/apps/gitlab/repositories/continuous-delivery/cd-test.git/hooks
[root@git-cd hooks]# ll
total 48
-rwxrwxr-x. 1 git git 452 Jun 10 06:01 applypatch-msg.sample
-rwxrwxr-x. 1 git git 896 Jun 10 06:01 commit-msg.sample
-rwxrwxr-x. 1 git git 44 Jun 11 00:37 post-receive
-rwxrwxr-x. 1 git git 41 Jun 11 00:38 post-update
-rwxrwxr-x. 1 git git 189 Jun 10 06:01 post-update.sample
-rwxrwxr-x. 1 git git 398 Jun 10 06:01 pre-applypatch.sample
-rwxrwxr-x. 1 git git 1642 Jun 10 06:01 pre-commit.sample
-rwxrwxr-x. 1 git git 1281 Jun 10 06:01 prepare-commit-msg.sample
-rwxrwxr-x. 1 git git 1352 Jun 10 06:01 pre-push.sample
-rwxrwxr-x. 1 git git 4972 Jun 10 06:01 pre-rebase.sample
lrwxrwxrwx. 1 git git 57 Jun 10 06:01 update -> /opt/gitlab-6.9.2-0/apps/gitlab/gitlab-shell/hooks/update
-rwxrwxr-x. 1 git git 3611 Jun 10 06:01 update.sample
Run Code Online (Sandbox Code Playgroud)
这两个文件都包含一个脚本,用于向现有文件添加新行"post-receive-2" >> /var/log/hooks_test.log.然后将更改从本地计算机推送到服务器.但它仍然没有附加文本.
更新2
收到后的剧本是错误的,它没有回音.在我添加echo之后(echo "post-receive-2" >> /var/log/hooks_test.log然后它按预期工作!
Von*_*onC 11
那是因为那些卫星回购不是你要推送的那个,所以当你想到时(即,当有人推送到GitLab服务器时)他们的钩子不会触发.
PR 6185介绍了archicture概述文档
/home/git/gitlab-satellites- 从Web UI检出合并请求和文件编辑的存储库.这可以视为临时文件目录.Web界面使用卫星存储库来编辑存储库,而wiki也是一个git存储库.
你应该在裸仓中添加你的钩子~git/repositories.
或(更新Q4到2014年,从GitLab 7.5+ 2014年11月),你可以使用自定义的挂钩(而不是网络挂接),如下面提及的多卡.
必须在GitLab服务器的文件系统上配置自定义git挂钩.
只有GitLab服务器管理员才能完成这些任务.如果您没有文件系统访问权限,请浏览webhooks作为选项.
- 在GitLab服务器上,导航到项目的存储库目录.
对于手动安装,通常是路径/home/git/repositories/<group>/<project>.git.
对于Omnibus,通常会安装路径/var/opt/gitlab/git-data/repositories/<group>/<project>.git.- 在此位置创建一个名为的新目录
custom_hooks.- 在新
custom_hooks目录中,创建一个名称与钩子类型匹配的文件.
对于pre-receive钩子,文件名应该pre-receive没有扩展名.- 使钩子文件可执行,并确保它所拥有
git.