SVN Post-Commit Hook error 255

15,510

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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

Share:
15,510
Brendon Dugan
Author by

Brendon Dugan

Updated on July 19, 2022

Comments

  • Brendon Dugan
    Brendon Dugan almost 2 years

    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?

  • Brendon Dugan
    Brendon Dugan over 12 years
    Hmmm... no luck. I have made this change, and verified that svn is located at /usr/bin, but I still get the same error.
  • Mike Odie
    Mike Odie over 9 years
    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.
  • David Thompson
    David Thompson over 7 years
    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.
  • marcovtwout
    marcovtwout over 7 years
    Yup, I forgot chmod+x