为什么接收后挂钩不起作用?

时间:2018-07-15 15:21:57

标签: git jenkins hook

我的接收后挂钩不起作用。我检查过:

- 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

在接收后脚本中,我称为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]$ 

接收后的内容

[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]$

1 个答案:

答案 0 :(得分:1)

找到了! 文件结构中存在严重错误:

我对val set = HashSet<String>() 感兴趣 ,但应位于/opt/git/project.git/hooks/

自从我将钩子移到正确的位置后,它就可以正常工作!