SVN Post-Commit Hook error 255
Asked Answered
S

4

10

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?

Sickness answered 20/10, 2011 at 20:5 Comment(0)
L
6

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.

Lisp answered 20/10, 2011 at 20:8 Comment(3)
Hmmm... no luck. I have made this change, and verified that svn is located at /usr/bin, but I still get the same error.Sickness
Make sure to chmod +x the hook script. I was getting "post-commit hook failed (exit code 255) with no output." I had copied post-commit.tmpl to post-commit but did not change it to be executable.Paget
Another thing to mindful of is that the server id ("apache" in my case) specifically needs execute permission to the file (either by ownership or group/world access). Personally ran into a project where my pre-commit script was group executable, but overlooked that apache was not in that project group. Since apache already owned pre-commit.tmpl, just moved that to pre-commit, as I did not want to add world execute nor hassle with managing apache's groups.Althing
S
5

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

Sickness answered 28/10, 2011 at 20:32 Comment(0)
C
1
  • Don't forget add #!/bin/sh in your post-commit hook.Use #!/bin/env python if you are using python
  • Make sure the permission chmod a+x post-commit
  • Make sure commands in your hook is installed and reachable.

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.

Caceres answered 22/12, 2015 at 8:47 Comment(1)
Yup, I forgot chmod+xVeteran
H
1

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

Hindorff answered 19/9, 2018 at 0:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.