Click here to Skip to main content
14,664,409 members
Articles » Development Lifecycle » Design and Architecture » Methodologies
Posted 3 May 2008


41 bookmarked

Secrets for Setting Up Continuous Integration

Rate this:
2.88 (7 votes)
Please Sign up or sign in to vote.
2.88 (7 votes)
23 Feb 2009CPOL
A few simple tips that should help when you are considering setting up CI


I've set up CI in my last two roles and have spent a little bit of time trying to simplify the process whilst doing it and thought I'd share a few 'secrets of success' for getting CI up and running.

What Makes Setting Up CI Easier

1. Generate Your Build Files

I wrote my own code generator that searches through my entire dev directory for project files (I work with .NET so it simply looks for *.csproj files) and generates a NAnt build file for each project file. I also generate the file. If there isn't already an existing CodeSmith template for this type of thing, then it's not too hard to create your own generator (code generator = fancy string builder). I'm also happy to share the generator if anyone is interested (will put up on CodePlex).

Generating your build files is also important because you then know that all of your projects are built in a consistent manner. Plus when you make the build files cleverer, you can easily apply those changes across all of your build files at the push of a button (ok a few buttons maybe).

It's taken a while, but I've finally made my source available on CodePlex.

2. Automate and Control Your Database Update Process

This is a whole other topic in itself but I'll try to keep it brief (of course ignore this one if your app does not hit a database). The biggest challenge you will face is handling database updates effectively. Your build box, test box and of course production box all have their own database and ideally each developer runs his/her own local copy (unless size does not permit). The problem is, when a developer checks in his/her unit of work which includes a database change (new table and some data for example), when the build kicks off how do you ensure that those database changes are run against the build boxes database?

You must have an automated program that runs any new scripts and this program must be one of the first things run as part of your build process. So what if one of the scripts fails? Ideally your program will run all scripts in a transaction and simply rollback the transaction if any of the scripts fail. This will work on SQL Server but sadly on Oracle any DML script will cause a commit of the transaction so you must find another (like backup first and restore on failure).

Developers use the same program to update their local database and the program is also used when promoting to other environments. By the time you run it against production, you will potentially have hundreds of scripts (which I have experiences) so make sure you have a good naming convention (or other technique) that ensures the scripts get run in the correct order.

All changes to the database must be made with a script, no exceptions. (not exactly a new rule but it amazes me how many people do not follow it!)

I wrote my own program to handle this and I'd be very interested to hear what others have done. I've been meaning to put the source (C#) up on CodePlex for ages, let me know if you are interested and I'll let you know when it goes up.

See the link below for the Automated Database Updater on CodePlex!

3. Get 'Buy In' Before Starting

From developers to the CIO. The CIO needs to understand the benefits that this new process will provide because it is going to take time (and money) to get it setup (money and time that will DEFINITELY be recouped over time).

CI forces a more disciplined approach to software development, some developers will not like that so it's important that they understand the benefits that they will see with the new process (like knowing that doing a get latest will always return a working copy of the source!). Developers will get annoyed with the new process if they don't understand it properly and keep breaking the build.

4. Get A Decent Build Box

We are still working with a crappy old desktop. It takes longer to build and we continually have to clean it up as it fills up pretty quickly. Frustrating!

5. Make Rules From Day 1

  • #1 - If you break the build, it becomes your highest priority to fix it.
  • #2 - If the build is broken, no further checkins are allowed until it is fixed (except of course by the guy fixing).
  • #3 - No chicken runs...means no checking in just before you go home (This rule is the only one that is flexible.)

6. Clean Build

If you delete everything in your development directory on your build box (i.e. where all of the source code is) and then start the build, should work! If it doesn't then there is a dependency in there somewhere that is not in source control.


Every developer I have spoken to who has used CI tells me there is no way she/he could work in an environment that does not use it, so it may present some challenges setting it up but it is well worth it!

If you are not doing CI....what are you waiting for!

Points Of Interest

I should also mention that this is one of the few articles I'm working on relating to build processes and 'simplifying the boring stuff' so you can focus on what you really enjoy...writing cool code! Other articles:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Peer Placements Pty Ltd
Australia Australia
I live in Sydney and have been a developer for almost a decade now. I have a passion for technology and a strong interest in discovering 'better, cleaner, faster' ways to get systems out the door because I believe software development takes too long. If I have an idea I want to realise it as quickly as writing systems for someone else I want to deliver quickly so I can move onto the next interesting project!

Comments and Discussions

GeneralGood first article Pin
Donsw21-Mar-09 17:38
MemberDonsw21-Mar-09 17:38 
GeneralMy vote of 2 Pin
Priyank Bolia2-Mar-09 21:29
MemberPriyank Bolia2-Mar-09 21:29 
GeneralRe: My vote of 2 Pin
wallism3-Mar-09 12:59
Memberwallism3-Mar-09 12:59 
GeneralBTW: IMO Database upgrade and database diff/merge are two different concepts Pin
liron.levi24-Feb-09 0:50
Memberliron.levi24-Feb-09 0:50 
GeneralDatabase diff/merge is a sticky problem Pin
liron.levi24-Feb-09 0:29
Memberliron.levi24-Feb-09 0:29 
GeneralRe: Database diff/merge is a sticky problem Pin
wallism3-Mar-09 13:21
Memberwallism3-Mar-09 13:21 
GeneralRe: Database diff/merge is a sticky problem Pin
liron.levi4-Mar-09 2:26
Memberliron.levi4-Mar-09 2:26 
QuestionWhat is it? Pin
PIEBALDconsult23-Feb-09 11:59
professionalPIEBALDconsult23-Feb-09 11:59 
AnswerRe: What is it? Pin
wallism28-Feb-09 14:35
Memberwallism28-Feb-09 14:35 
General[Message Removed] Pin
Mojtaba Vali25-May-08 17:53
MemberMojtaba Vali25-May-08 17:53 
GeneralAutomated Database Updater Pin
wallism25-May-08 6:04
Memberwallism25-May-08 6:04 
GeneralChicken Runs Pin
Mark Potter8-May-08 2:15
MemberMark Potter8-May-08 2:15 
#3 - No chicken runs...means no checking in just before you go home. (this rule is the only one that is flexible)
At my last place of employment we had a rule among the developers: If you left for the day with the automated build system broken and you broke it, then you owed all the developers ice cream. (It was only about eight people, but you get the idea.) Therefore, if I ever got to the point of doing a check it and it was near the end of the day, I would always delay the check in until the next morning.
GeneralSource PLEASE Pin
Bernhard Hofmann6-May-08 21:42
MemberBernhard Hofmann6-May-08 21:42 
GeneralRe: Source PLEASE Pin
wallism23-Feb-09 11:07
Memberwallism23-Feb-09 11:07 
GeneralRe: Source PLEASE Pin
Bernhard Hofmann23-Feb-09 21:41
MemberBernhard Hofmann23-Feb-09 21:41 
GeneralDatabase automation. Pin
Member 46697556-May-08 10:17
MemberMember 46697556-May-08 10:17 
GeneralRe: Database automation. Pin
MaxGuernsey7-May-08 11:32
MemberMaxGuernsey7-May-08 11:32 
GeneralRe: Database automation. Pin
Paul B.7-May-08 14:18
MemberPaul B.7-May-08 14:18 
GeneralRe: Database automation. Pin
MaxGuernsey7-May-08 14:52
MemberMaxGuernsey7-May-08 14:52 
GeneralRe: Database automation. Pin
Paul B.9-May-08 9:27
MemberPaul B.9-May-08 9:27 
GeneralRe: Database automation. Pin
MaxGuernsey9-May-08 9:59
MemberMaxGuernsey9-May-08 9:59 
GeneralSave time - TeamCity... Pin
robdkenyon5-May-08 4:42
Memberrobdkenyon5-May-08 4:42 
GeneralRe: Save time - TeamCity... Pin
Member 46697556-May-08 10:18
MemberMember 46697556-May-08 10:18 
GeneralAgreed. Pin
robdkenyon6-May-08 13:03
Memberrobdkenyon6-May-08 13:03 
GeneralDatabase update process Pin
Todd Smith3-May-08 10:03
MemberTodd Smith3-May-08 10:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.