Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I configure SVN to deploy when I commit? I would like to deploy when I commit

share|improve this question
    
Where do you want to deploy? On the repository (SVN) server, on a build server, on another workstation? –  Shi Sep 11 '12 at 21:39
    
on the same server, I would like to put all files in a directory –  barroco Sep 11 '12 at 21:57
add comment

2 Answers

up vote 2 down vote accepted

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
share|improve this answer
    
I think that you should mention that the instruction applies only to linux machines. –  bahrep Sep 12 '12 at 8:45
    
Good point. It works also on Mac OS and in every system that suports SVN & Shell. Are there others? :P –  Mauro Sep 12 '12 at 15:36
add comment

look at hook scripts section at Repository Creation and Configuration you can write a shell script to do pretty much anything/anywhere...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.