views:

1374

answers:

1

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

+3  A: 

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
Wim Coenen
That helped immensely - a thousand thank yous!The log file details the problem I've got: Error validating server certificate for <server>: - The certificate is not issued by a trusted authority. Use the fingerprint to validate the certificate manually! (R)eject, accept (t)emporarily or accept (p)ermanently? svn: PROPFIND request failed on '/live' svn: PROPFIND of '/live': Server certificate verification failed: issuer is not trusted (<server>)So basically, we're using a self-cert SSL and I need some way of accepting it permanently.Any ideas?
meanstreakuk
Ah, that's covered in the SVN book here: http://svnbook.red-bean.com/en/1.5/svn.serverconfig.httpd.html#svn.serverconfig.httpd.authn.sslcerts
Wim Coenen
the `servers` file mentioned there can be found in `~/.subversion/` and is described here: http://svnbook.red-bean.com/en/1.5/svn.advanced.confarea.html#svn.advanced.confarea.opts.servers
Wim Coenen
Brilliant. Cheers for your help people...
meanstreakuk