views:

544

answers:

3

I'm working on my first rails app and am struggling trying to find an efficient and clean solution for doing automated checkouts and deployments.

So far I've looked at both CruiseControl.rb (having been familiar with CruiseControl.NET) and Capistrano. Unfortunately, unless I'm missing something, each one of them only does about half of what I want (with each one doing a different half).

For what I've seen so far:

CruiseControl

  • Strengths
    • Automated builds on repository checkouts upon commit
    • Also runs unit/functional tests and reports back
  • Weaknesses
    • No built-in deployment mechanisms (best I can find so far is writing your own bash scripts)

Capistrano

  • Strengths
    • Built for deployments
  • Weaknesses
    • Has to be kicked off via a command (i.e. doesn't do automated checkouts upon commit)

I've found ways that I can string the two together -- i.e. have CruiseControl ping the repository for changes, do a checkout upon commit, run the tests, etc. and then make a call to Capistrano when finished to do the deployment (even though Capistrano is also going to do a repository checkout).

Basically, when all is said and done, I'd like to have three projects set up:

  • Dev: Checkout/Deployment is entirely no touch. When someone commits a file, something checks it out, runs the tests, deploys the changes, and reports back
  • Stage: Checkout/Deployment requires a button click
  • Prod: Button click does either a tagged check out or moves the files from stage

I have this working with a combination of CruiseControl.NET and MSBuild in the .NET world, and it was fairly straightforward. I would guess this is also a common pattern in the ruby deployment world, but I could easily be mistaken.

+1  A: 

I would use two system to build and deploy anyway. At least two reasons: you should be able to run it separately and you should have two config files one for deploy and one for build. But you can easily glue the two systems together.

Just create a simple capistrano task, that tests and reports back to you. You can use the "run" command to do anything you want.

If you don't want any command line tool there was webistrano 2 years ago.

To could use something like http://github.com/benschwarz/gitnotify/tree/master to trigger the build deploy if you use git as repository.

Beffa
+2  A: 

I would give Hudson a try (free and open source). I started off using CruiseControl but got sick of having to relearn the XML configuration every time I needed to change a setting or add a project. Then I started using Hudson and never looked back. Hudson is more or less completely configurable over the web. It was initially a continuous integration tool for Java but has plugins for other development stack such as .NET and Ruby on Rails. There's a Rake plugin. If that doesn't work, you can configure it to execute any arbitrary command line after running your Rake builds/tests.

I should also add it's extremely easy to get Hudson going:

java -jar hudson.war

Or you can drop the war in any servlet container.

0sumgain
A: 

At least for development automated deployments, check out the hook scripts available in git:

http://www.kernel.org/pub/software/scm/git/docs/githooks.html

I think you'll want to focus on the post-receive hook script, since this runs after a push to a remote server.

Also worth checking out Mislav's git-deploy on github. Makes managing deployments pretty clean.

http://github.com/mislav/git-deploy

ajhit406