Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN Post-Commit Hook error 255

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?

like image 420
Brendon Dugan Avatar asked Oct 20 '11 20:10

Brendon Dugan


Video Answer


4 Answers

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

like image 132
Brendon Dugan Avatar answered Oct 17 '22 12:10

Brendon Dugan


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

like image 42
Mac Avatar answered Oct 17 '22 13:10

Mac


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.

like image 37
chown Avatar answered Oct 17 '22 14:10

chown


  • 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.

like image 1
user3790229 Avatar answered Oct 17 '22 12:10

user3790229