views:

390

answers:

4

I've been thinking about CI and automatic builds a lot lately and am interested in knowing if there are any best practices for setting up and maintaining a continuous integration environment. Do you keep all your CI related files checked in with your project source? How would you usually structure your CI and build files? Any tips are welcome!

+3  A: 

If you haven't already, definitely check out the Continuous Integration book from the Martin Fowler series, by Duvall/Matyas/Glover. It covers all of the questions you ask in depth with solid examples.

John Feminella
+2  A: 

There's also the Pragmatic Series' "Pragmatic Project Automation".

Of course, all files required to build have to be checked in. How else would CI get at them?

I've used CI with Java, so that means an Ant build.xml and either Cruise Control, Team City, or Hudson. It's possible for the build.xml to be generic if you stick with a consistent directory structure for your projects.

duffymo
Yep. You'll need to install several things on your build server, but the goal is to have all of your CI-related files under source control (and to have the CI server pull the files from there). We use TeamCity for C# development. If a build gets complex, we use NAnt (which can call MSBuild, too).
TrueWill
+1  A: 

If your build script starts getting big you can split it out and include the relevant parts. This makes maintenance and readability better.

My other advice would be unlike traditional programming - when making a build script make use of liberal amounts of comments.

Finglas
+3  A: 
  1. Start with a one step build. If you don't have that, you can not have any reasonable CI
  2. If it isn't in source control, it doesn't exist
  3. If setting up and maintaining your CI exceeds the effort of setting up a developer workstation then you are overly dependent on your IDE or your project structure is overly complicated. Consider that as a refactoring opportunity.
  4. You don't need anything fancy to do CI. You don't even need to know what it is to do it. I wrote about my earlier experience here, when I implemented a naive CI before I ever heard the term CI.
sal