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