tags:

views:

557

answers:

10

I'm introducing Subversion into our web shop. I want to want the checked in files to be uploaded into the server via FTP (and as they get use to Subversion, via SFTP). The files are sent to a release candidate page for testing purposes. A script can be called to move the files into production.

My question is this: How do you transfer the files to the server via Subversion? Is there a script I can add that will do the transfer when the files are checked in?

+1  A: 

I think what you're looking for is something like integration with an automatic build script. I have used CruiseControl to do a similar thing with an ASP.Net application. I don't know your exact requirements but I'd bet you could get it to do what you want.

lomaxx
A: 

I'll evaluate CruiseControl this week. See if I can get it to work on our shop.

Anybody else has any suggestions?

MrValdez
+1  A: 

Post commit scripts are useful for this. Essentially on every commit a script is called after the event, which you can use to perform an svn export to where-ever.

An interesting article shows how this might be done, and this shows how hook scripts can be used with subversion

roo
+1  A: 

You can probably use the SVN "hooks" to do this. Basically, you can configure your server to run scripts before or after every checkin. Here's the direct link to the relevant section of the online book.

Pat Notz
+2  A: 

You want to build a script that uses the post commit hook in SubVersion. You can either have the script export from your repository and then FTP to the server, or you can just checkout from your repository into a working directory on your server and call "svn update" on the servers working directory in your post-commit hook script.

There's more information in the Subversion FAQ

ScottKoon
+3  A: 

If you have shell access to your sever, and SVN installed on it (or the ability to install SVN), then your best bet may be just to bypass FTP entirely.

How we deploy our apps is (simplified)

  • Developers write code and check it into trunk
  • Periodically, when trunk is stable, we will take a snapshot of it as a tag
  • On the server, svn checkout the tag

If any changes need to be made to the server (or directly on the live server itself) it is trivial to use subversion to sync the code

Orion Edwards
A: 

I second Orion's idea. If you've got shell access to the server, it's actually extremely easy to use Subversion itself as the deployment tool. Just make sure you have some web server rules set up so that you don't accidentally expose the .svn directories.

Bob Somers
A: 

Thanks for all the suggestions. I would be testing out each one of them this week (or longer), so it might get a while for me to select an accepted answer.

Keep the suggestions coming. :D

MrValdez
+2  A: 

I think you should probably use svn export rather than svn checkout for deployments, so you don't have those .svn directories muddying up your production backup jobs. svn export is a "clean" checkout.

I'd also create a script that handles it all for you. Depending on how your code is structured, you can often version your directories and just update a symlink to the latest version, which makes rollbacks easier.

You could even use something like Capistrano to automate the deployments. I second the recommendation for CruiseControl, though.

The How-To Geek
A: 

svn2web will ftp or scp files from a subversion repository to a web server on every commit. See the SourceForge project for details.

gavinandresen