Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Permission problem when pulling using post-receive hook

Content Formula June 5, 2013

I keep receiving remote: error: cannot open .git/FETCH_HEAD: Permission denied

when post-recive hook is executed

I have stash 2.4 setup to run as dedicated user so post-receive hook is being executed as a stash user.

Hook code

#!/bin/sh


echo "**** Pulling changes into Development Box ****"
echo "User name $USER"
echo

cd /var/www/dir || exit
unset GIT_DIR

git pull origin develop
echo "**** DONE ****"

exec git-update-server-info

I also use .netrc to authenticate stash user (correct access to repo) over HTTP. I'm able to pull with no problems using linux user who run stash if I do it manually but it doesn't work as a hook.

1 answer

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2013

Hi Content Formula,

This is not related to network permissions, just the filesystem. The script is running as the same user as Stash, which is then cd'ing in the /var/www/dir, which I can only assume doesn't grant write access. When you say you're able to pull, do you mean from that directory?

Cheers,

Charles

PS. You may also be interested in voting for and watching the following:

https://jira.atlassian.com/browse/STASH-3230

I suspect someone will eventually release a nice plugin that does this without the need for shell scripts.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events