为什么 post-receive 挂钩不起作用?
Why does the post-receive hook not work?
我的post-接收挂钩不起作用。我检查过:
- it is named post-receive and resides in server's repos hooks folder
- it is executable and the owner is git
- I can execute it manually as user git
在 post-receive 脚本中,我调用 jenkins 进行构建。但看起来,脚本根本没有执行。
这里会出什么问题?
[toki@v22018076590769xxx ~]$ cd /opt/git/project.git/hooks/
[toki@v22018076590769xxx hooks]$ ls -l
insgesamt 44
-rwxrwxr-x. 1 root git 452 14. Jul 19:59 applypatch-msg.sample
-rwxrwxr-x. 1 root git 896 14. Jul 19:59 commit-msg.sample
-rwxrwxrwx. 1 git git 204 15. Jul 16:05 post-receive
-rwxrwxr-x. 1 root git 189 14. Jul 19:59 post-update.sample
-rwxrwxr-x. 1 root git 398 14. Jul 19:59 pre-applypatch.sample
-rwxrwxr-x. 1 root git 1704 14. Jul 19:59 pre-commit.sample
-rwxrwxr-x. 1 root git 1239 14. Jul 19:59 prepare-commit-msg.sample
-rw-rw-r--. 1 root git 1348 14. Jul 19:59 pre-push.sample
-rwxrwxr-x. 1 root git 4951 14. Jul 19:59 pre-rebase.sample
-rwxrwxr-x. 1 root git 3611 14. Jul 19:59 update.sample
[toki@v22018076590769xxx hooks]$
post-接收内容
[toki@v22018076590769xxx hooks]$ cat post-receive
#!/bin/sh
echo "starting post-commit hook"
/usr/bin/curl --user xxxxx:xxxxxx -s \
http://v22018076590769xxx.powersrv.de:8080/jenkins/job/Weasy/build?token=build_weasy
echo "post-commit hook finihed"
[toki@v22018076590769xxx hooks]$
找到了!
文件结构中存在严重错误:
我把钩子放到/opt/git/project.git/hooks/
, 但它应该位于 /opt/git/project.git/.git/hooks/
由于我将挂钩移到了正确的位置,所以效果很好!
我的post-接收挂钩不起作用。我检查过:
- it is named post-receive and resides in server's repos hooks folder - it is executable and the owner is git - I can execute it manually as user git
在 post-receive 脚本中,我调用 jenkins 进行构建。但看起来,脚本根本没有执行。 这里会出什么问题?
[toki@v22018076590769xxx ~]$ cd /opt/git/project.git/hooks/
[toki@v22018076590769xxx hooks]$ ls -l
insgesamt 44
-rwxrwxr-x. 1 root git 452 14. Jul 19:59 applypatch-msg.sample
-rwxrwxr-x. 1 root git 896 14. Jul 19:59 commit-msg.sample
-rwxrwxrwx. 1 git git 204 15. Jul 16:05 post-receive
-rwxrwxr-x. 1 root git 189 14. Jul 19:59 post-update.sample
-rwxrwxr-x. 1 root git 398 14. Jul 19:59 pre-applypatch.sample
-rwxrwxr-x. 1 root git 1704 14. Jul 19:59 pre-commit.sample
-rwxrwxr-x. 1 root git 1239 14. Jul 19:59 prepare-commit-msg.sample
-rw-rw-r--. 1 root git 1348 14. Jul 19:59 pre-push.sample
-rwxrwxr-x. 1 root git 4951 14. Jul 19:59 pre-rebase.sample
-rwxrwxr-x. 1 root git 3611 14. Jul 19:59 update.sample
[toki@v22018076590769xxx hooks]$
post-接收内容
[toki@v22018076590769xxx hooks]$ cat post-receive
#!/bin/sh
echo "starting post-commit hook"
/usr/bin/curl --user xxxxx:xxxxxx -s \
http://v22018076590769xxx.powersrv.de:8080/jenkins/job/Weasy/build?token=build_weasy
echo "post-commit hook finihed"
[toki@v22018076590769xxx hooks]$
找到了! 文件结构中存在严重错误:
我把钩子放到/opt/git/project.git/hooks/
, 但它应该位于 /opt/git/project.git/.git/hooks/
由于我将挂钩移到了正确的位置,所以效果很好!