Project

General

Profile

Post Commit Hook Help

Added by Tim Davis almost 16 years ago

I'm trying to do a post commit hook to run the commit fetch, but for some reason I just cannot get it to work. Here's what I have in the post-commit.tmpl

#!/bin/sh

  1. POST-COMMIT HOOK #
  2. The post-commit hook is invoked after a commit. Subversion runs
  3. this hook by invoking a program (script, executable, binary, etc.)
  4. named 'post-commit' (for which this file is a template) with the
  5. following ordered arguments: #
  6. [1] REPOS-PATH (the path to this repository)
  7. [2] REV (the number of the revision just committed) #
  8. The default working directory for the invocation is undefined, so
  9. the program should set one explicitly if it cares. #
  10. Because the commit has already completed and cannot be undone,
  11. the exit code of the hook program is ignored. The hook program
  12. can use the 'svnlook' utility to help it examine the
  13. newly-committed tree. #
  14. On a Unix system, the normal procedure is to have 'post-commit'
  15. invoke other programs to do the real work, though it may do the
  16. work itself too. #
  17. Note that 'post-commit' must be executable by the user(s) who will
  18. invoke it (typically the user httpd runs as), and that user must
  19. have filesystem-level permission to access the repository. #
  20. On a Windows system, you should name the hook program
  21. 'post-commit.bat' or 'post-commit.exe',
  22. but the basic idea is the same.
  23. The hook program typically does not inherit the environment of
  24. its parent process. For example, a common problem is for the
  25. PATH environment variable to not be set to its usual value, so
  26. that subprograms fail to launch unless invoked via absolute path.
  27. If you're having unexpected problems with a hook program, the
  28. culprit may be unusual (or missing) environment variables.
  29. Here is an example hook script, for a Unix /bin/sh interpreter.
  30. For more examples and pre-written hooks, see those in
  31. the Subversion repository at
  32. http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
  33. http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/

REPOS="$1"
REV="$2"

commit-email.pl "$REPOS" "$REV"
log-commit.py --repository "$REPOS" --revision "$REV"
cd /home/binaryme/rails/tickets
ruby script/runner "Repository.fetch_changesets" -e production


Replies (4)

RE: Post Commit Hook Help - Added by Tim Davis almost 16 years ago

Ok, so after reading some stuff on Subversion I created a new file name post-commit and removed the tmpl file. I also made this file executable.

The contents of the file is:

#!/bin/bash

cd /home/binaryme/rails/tickets
ruby script/runner "Repository.fetch_changesets" -e production

But still no luck...can anyone see ewhat I am doing wrong?

RE: Post Commit Hook Help - Added by Tim Davis almost 16 years ago

Ok, I have tried everything, and I can't figure it out, my post-commit hook is running fine, but for some reason Redmine just isn't seeing the changes...

post-commit
------------
REPOS="$1"
REV="$2"
LOG=/home/binaryme/repositories/testrepo/hooks/test.txt
echo "Got Repos $REPOS and Revision $REV" >> $LOG
RUBY=/usr/bin/ruby
echo "Set Ruby: $RUBY" >> $LOG
APP=/home/binaryme/rails/tickets/script/runner
echo "Set App: $APP" >> $LOG
$RUBY $APP "Repository.fetch_changesets" -e production >> $LOG
echo "Fetched Changes" >> $LOG

Should I be doing something else?

RE: Post Commit Hook Help - Added by Brad Miller over 15 years ago

Sorry for resurrecting an older thread. I found this thread while searching for an answer for the same issue. I don't know if the original poster figured this out, but I found a solution that got it working for me and wanted to post in case others ran into it. The thread came up number 2 in google for me.

The solution I found was to edit lib/redmine/scm/adapters/subversion_adapter.rb and change the path listed for SVN_BIN on line 28 to the full path to the svn binary on my server. The path to the binary isn't in the path of the user that the post-commit script gets run under for me.

RE: Post Commit Hook Help - Added by Francisco Ramirez over 11 years ago

Brad Miller wrote:

Sorry for resurrecting an older thread. I found this thread while searching for an answer for the same issue. I don't know if the original poster figured this out, but I found a solution that got it working for me and wanted to post in case others ran into it. The thread came up number 2 in google for me.

The solution I found was to edit lib/redmine/scm/adapters/subversion_adapter.rb and change the path listed for SVN_BIN on line 28 to the full path to the svn binary on my server. The path to the binary isn't in the path of the user that the post-commit script gets run under for me.

Thanks I had the same problem with a svn hook, but for Redmine 2.3.0.stable.11744, and SVN 1.6.17 on Ubuntu 12.04 you have to modify the /config/configuration.yml and put the full path in a svn property like this:
scm_subversion_command: /usr/bin/svn

    (1-4/4)