4
votes

We have a staging version of our web application (it is basically a subversion working copy that no-one works on) that lives in '/apps/software'. Each developer has their own working copy in '~/apps/software'. I would like to utilise a simple post-commit hook script to update the staging copy every time a developer commits a change to the repository.

Sounds simple right? Well I've been banging my head against a brick wall on this for longer than I should. The hook script (called 'post-commit', located in /svn/software/hooks, permissions=777, user:group=apache:dev) is as follows (ignore the commented out bits for now):

#!/bin/sh

/usr/bin/svn update /apps/software >> /var/log/svn/software.log

# REPOS="$1"
# REV="$2"
# AUTHOR=`/usr/bin/svnlook author -r "$REV" "$REPOS"`
# LOG=`/usr/bin/svnlook log -r "$REV" "$REPOS"`
# EMAIL="[email protected]"

# echo "Commit log message as follows:-
#
# \"${LOG}\"
#
# The staging version has automatically been updated.
#
# See http://trac/projects/software/changeset/${REV} for more details." | /bin/mail -s "SVN : software : revision ${REV} committed by ${AUTHOR}" ${EMAIL}

That's it. The log file has the same permissions and user:group as the post-commit script and I have even given the staging copy the same user:group and permissions. Apache itself (we're using the apache subversion extension) is running under apache:dev as well. I know the hook is being executed, because the stuff that's commented out above sending an email works fine - it's just the update command that isn't.

I can also execute the post-commit hook script without environment variables using:

$ env - /svn/software/hooks/post-commit /svn/software <changeset>

and it runs fine, performing the 'svn update' no problems. I have even tried removing the '>>' to log file, but it doesn't make a difference.

Any help on this would be most appreciated...

1
Not that it has anything to do with your problem, but your shebang says "sh" and the tag on your question says "bash".Dennis Williamson
OK, I've gone for the more broad 'shell' tag.Dan Herd

1 Answers

3
votes

Your only sending standard output to the log here, not error output:

/usr/bin/svn update /apps/software >> /var/log/svn/software.log

Do this instead to see what is going wrong:

/usr/bin/svn update /apps/software >> /var/log/svn/software.log 2>&1