How can I configure SVN to deploy when I commit? I would like to deploy when I commit
3 Answers
You need to modify the post commit hook. Placed here:
PATH_TO_YOUR_REPO/hooks/post-commit.tmpl
Change it's name (or create a new one and save that one for future reference) to:
PATH_TO_YOUR_REPO/hooks/post-commit
Then chown
it and chmod
it let your svn user (tipically apache
) execute that file:
chown apache.apache PATH_TO_YOUR_REPO/hooks/post-commit
chmod g+x PATH_TO_YOUR_REPO/hooks/post-commit
Assuming you want to export your repo's trunk to a local path, here is what I use to automatically deploy to my testing server, which is also my SVN repo server (I do not recommend using this to deploy to production servers, use a custom script for that). This will look for a **DEPLOY**
tag in your commit message and deploy only if that's the case.
#!/bin/sh
REPO="$1"
REV="$2"
if ( svnlook log -r $REV $REPO | grep "**DEPLOY**" ) then
svn export --force -r $REV "file://$REPO/trunk" /var/www/html/yourapp
fi
look at hook scripts section at Repository Creation and Configuration you can write a shell script to do pretty much anything/anywhere...
It is possible, but not recommended to use post commit hook. It will make developer to wait for the commit to complete until the hook execution has finished.
For professional solution Continuous Integration tool should be used, like: CruiseControl, Jenkins or one of many other.