代码之家  ›  专栏  ›  技术社区  ›  tobi

为什么后收钩不工作?

  •  1
  • tobi  · 技术社区  · 8 年前

    我的收银钩坏了。我查过了:

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

    收发内容

    [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 回复  |  直到 8 年前
        1
  •  1
  •   tobi    8 年前

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

    我把钩子放在 /opt/git/project.git/hooks/ ,但它应该位于 /opt/git/project.git/.git/hooks/

    因为我把钩子移到了正确的位置,所以它工作得很好!