adelriosantiago
adelriosantiago

Reputation: 8124

Auto SVN update inside server for website management

I would like to know how to automatically perform and SVN update on a external server once that it detects that new code has been commited.

I'm more or less new to revision control software like SVN and setted up a SVN repository on htdocs expecting that when I did a commit on my desktop computer the changes would be updated on the server and the webpage would be updated. However SVN stores the files in a database (they are not visible on the repository folder) so what I have to do to view the changes on the website is to perform a local checkout on the server from the repository to the htdocs folders...

How could I perform an svn auto update on the server? I know that this would be troublesome if many users try to commit changes, but I'm more interested in the "versioning features" rather than the "multiple users collaboration feature".

Thanks

Upvotes: 1

Views: 522

Answers (1)

Steve Barnes
Steve Barnes

Reputation: 28380

You could put in place on your server a cron job that just runs an update every hour or every midnight but better would be either to change your workflow so as to use a batch file or script to perform your commits or best of all yet put a post commit hook in place that does a checkout on your server whenever there is a new commit, or even a new commit from a specific user, e.g. You or a Release Manager. You could also set up a full blown SVN web sever - this is probably more work than you need unless you are letting a lot of people have SVN access to your working environment via the web.

See here for some examples of hooks.

So your options are:

  1. Automatically get any updates every x time - easy to do but the web site will be out of date until up to x time has elapsed.
  2. Use a different commit method - also easy but will only work for those that use the new method.
  3. Use post commit hooks - best of all works for everybody and always updates on successful commit but never in between.
  4. Full Blown Web Server - lots of work!

Added hook details from OP

Many thanks for the quick response Steves! Confirmed option 3 works very well, to enrich the answer even more, if someone else wants to do the same, this is the code that I used on "post-commit" hook (note the no extension):

#!/bin/sh sudo svn update [path to working copy] >> [path to log] 

The >> [path to log] is optional of course. Also the file post-commit was converted to file permission 755. – Alejandro del Río

Upvotes: 2

Related Questions