07 April 2008

I have a new Rails project I'm working on and I use Git/GitHub for source control. It was time to setup continuous integration, and my usual weapon of choice for that is CruiseControl.rb. Here's what I did to get my project setup under CruiseControl.rb with Git, on an Ubuntu 7.10 machine...

Setup for accessing GitHub repo

All I needed to do here was generate an SSH key for my account on the host machine, and then add that key to the allowed keys for my GitHub account.

Prerequisites

I setup a builder@mydomain.com email address which will get used by CruiseControl for sending build related emails/notifications.

You'll need to determine a port you want CruiseControl to run on, and your strategy for accessing it. For example, I run mine on a port other than port 80, and other than the default 3333. I then proxy that via Nginx, and also use Nginx to password protect access to it (since this is not a public project, etc. This will affect the CC dashboard URL setting specified below. Some notes on this:

I did my initial Nginx configuration using err's Nginx config generator. However, this makes a lot of path assumptions, and various other things, so you'll definitely want to go through the resulting file closely. I had a few sites on this server, so it was relatively useful to use this as a base starting point, and then just fix up paths to the access and error logs, and the PID file.

Install CruiseControl and Do Site Configuration

Cloned the Git version of CruiseControl.rb in location I wanted it (you could also simply download it and expand the tarball): git clone git://github.com/benburkert/cruisecontrolrb.git

The DEPENDENCIES file indicated I needed to have the grit and mime-types gems, so installed those.

Where your projects get stored for CruiseControl.rb is now defined by the CRUISE_DATA_ROOT environment variable, and if you don't set this, it defaults to $HOME/.cruise. I personally changed this to be /var/cruisecontrolrb.

Edit the config/site_configuration.rb (probably need to rename the example version accordingly) to set site-wide settings, such as your email config and so on.

For email setup, I use Gmail for domains, so I have a block like this:

You'll want to specify the Configuration.dashboard_url setting so URL's work properly.

There are a variety of other settings available in the file that you may want to tweak.

Add Project and Configure

Did the usual usual cruise add command to add my project, but with the Git variant: ./cruise add MyProjectName --git-url git@github.com:mylogin/myproject.git (modify the Git project URL for your Git repo of course). Note that you can see all the options by doing a ./cruise add

Create the test database for your project. The easiest way is just to go into $CRUISE_DATA_ROOT/projects/MyProjectName/work and do a rake db:create RAILS_ENV=test. Your first build will have already failed because this hasn't been made, this step hopefully fixes that.

Setup CruiseControl.rb Service/Daemon

I set the port for CruiseControl.rb to run on in the above /etc/init.d/cruisecontrolrb daemon file, by adding "--port 1234" (for example) to the DAEMON_ARGS variable.

Start the CruiseControl.rb daemon as appropriate for your system (e.g. "sudo /etc/init.d/cruisecontrolrb start").

Finally, surf to your cc.rb site on the web and see how your build has done. If you run into build problems, you'll want to look at the cc.rb build logs (if it was your project test/build that failed) which are in the $CRUISE_DATA_ROOT/projects/MyProjectName directory (or rather, the subdirectory in there for the particular build). And Enjoy!

Everyone has their own unique skills. I do not have the same ones that you do. I am most impressed by yours. You might as well be talking alien swheeli to me. That is sad, huh. I am most impressed with you and what you are doing. Keep it going.... K.C.

@christopher Please do not upload my blog posts to a file sharing service. They are copyrighted (see bottom of page). If you want to personally track them, then I suggest you bookmark them with del.icio.us or your bookmarking solution of choice. Thanks.

The fork from @benburkert didn't work for me and your instructions on how to add. I got a "all done" msg but the ~/.cruise/projects dir did not have a folder with my project after I ran the 'add'. Nor did @thoughtbot's, same behavior.

What did work was to download CC directly from GH here:

http://github.com/thoughtworks/cruisecontrol.rb/tree/master

They now have support from git, even though in their own website they state they don't.

I figured out the command to run by looking up help, and it was like this:

./cruise add [project-name] --url [source control URL] -s git

Thanks for putting together the details for the complete installation.

Have any of you tried to use ruby 1.9 with CruiseControl.rb and git ? I know officially cruisecontrol.rb supports only 1.8.4 and 1.8.5 but wanted to know if anyone has ported cruisecontrol.rb to ruby 1.9.

I've only used it with Ruby 1.8.6. But, it's on GitHub, so you can certainly try it and make any fixes for 1.9 (and contribute them back of course :) I would really doubt that CC would be all that hard to fix up for 1.9.

About Me

Chris

Eugene, Oregon, United States

I am the VP of Engineering at DealBase.com (the largest hotel deals web site), an independent software developer, as well as VP of Engineering at Bring Light. And for the non-professional side of life, I have a great family with two small kids, love to ride bicycles, and enjoy living in Eugene, OR.