What user runs the git hook?

后端 未结 2 912
梦毁少年i
梦毁少年i 2020-12-29 21:05

I have a post-update hook on my server, such that when I

git push

it does a pull on the live web directory. However, while the push always

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 21:42

    I decided to test this on my gitlab 6 server by creating a pre-receive hook and echoing out the user information

    $ cat /home/git/repositories/foo/foo.git/hooks/pre-recieve
    #!/bin/bash
    set -x
    echo -e "The user the hook is run as is $USER"
    echo -e "Just to doublecheck, the user is $(whoami)"
    exit 1
    

    It looks like it is run as the git user

    $ git push 
    Counting objects: 3, done.
    Delta compression using up to 8 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 269 bytes | 0 bytes/s, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: + echo -e 'The user the hook is run as is'
    remote: The user the hook is run as is
    remote: ++ whoami
    remote: + echo -e 'Just to doublecheck, the user is git'
    remote: Just to doublecheck, the user is git
    remote: + exit 1
    

提交回复
热议问题