I am trying to create a very simple post-commit hook for a repository I have set up on my server. The script is as follows:
REPOS="$1"
REV="$2"
cd /var/www/directory && svn update --username user --password pass
When I run a commit from my SVN client, I get the following error:
post-commit hook failed (exit code 255) with no output.
However, when I run my post-commit hook from cli with sudo bash post-commit, it executes perfectly. Any ideas about what I am doing wrong?
Ok, I have figured out the issue. It was a combination of a path issue (as suggested by chown, whose answer I will choose) and a permissions issue. I have written a blog post about the issue (as well as generally getting set up with SVN) which can be found at http://brennydoogles.wordpress.com
Also if the svn server is running under apache, and the operating system is running SElinux, remember to give apache permission to run the script, as in:
% chcon -t httpd_exec_t /home/svn/repos/hooks/post-commit
255 means a file wasn't found, try using the absolute path to all files:
REPOS="$1"
REV="$2"
cd /var/www/directory && /usr/bin/svn update --username user --password pass
The PATH env variable of the environment in which the post commit hook is running probably isn't set to include wherever the SVN executable lives.
#!/bin/sh
in your post-commit hook.Use #!/bin/env python
if you are using pythonchmod a+x post-commit
I meet this problem when running SVN in a docker(base on ubuntu) and use a post-commit hook for my Redmine sync:
curl "http://my.redmine.ip/sys/fetch_changesets?id=myproject&key=ETji9KUfs3XxLyyr6cRN"
I got error Warning: post-commit hook failed (exit code 255) with no output
.
Then I bash into my docker, run this hook manually and find out that 'curl' is not installed.
I install curl and run hook successfully, but still the same warning when commit.
After add #!/bin/sh
like this:
#!/bin/sh
curl "http://my.redmine.ip/sys/fetch_changesets?id=myproject&key=ETji9KUfs3XxLyyr6cRN"
Everything is fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With