MrValdez
MrValdez

Reputation: 8624

Subversion and web development

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?

Upvotes: 9

Views: 1039

Answers (8)

gavinandresen
gavinandresen

Reputation: 551

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

Upvotes: 0

The How-To Geek
The How-To Geek

Reputation: 1105

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.

Upvotes: 2

Bob Somers
Bob Somers

Reputation: 7316

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.

Upvotes: 0

Orion Edwards
Orion Edwards

Reputation: 123692

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

Upvotes: 3

ScottKoon
ScottKoon

Reputation: 3493

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

Upvotes: 3

Pat Notz
Pat Notz

Reputation: 214486

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.

Upvotes: 1

roo
roo

Reputation: 7196

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

Upvotes: 1

lomaxx
lomaxx

Reputation: 115885

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.

Upvotes: 1

Related Questions