Ayende @ Rahien

It's a girl

Requirements 101: Have an automated deployment

imageIf you don't have an automated deployment, it generally means that you are in a bad position. By automated, I mean that you should be able to push a new version out by double clicking something. If you can't get automated deployment script in under an hour, you most certainly have a problem.

Sometimes, the problem is with the process, you don't have the facilities to do an automated deployment because parts of the deployment is sitting in people's head (oh, you need to configure IIS to use Xyz with the new version), in other cases, it isn't there simply because people haven't tried.

Yet, automated deployment is one of those things that you can create in isolation, without getting commitment or support from the rest of the team. This is usually the first thing that I do in any project with existing codebase that I come to.

It is also a good way of taking care of problems in the process. If you have a hard time deploying because you database change management process is broken, you need to fix that before you can get an automatic deployment ready.

Also, notice that I am explicitly talking about automated deployment, not about having a build script. One of the requirements for automated deployment is a build script, but that is just one of them.

I don't care that you can or can't build the software, I care that you can deploy this successfully. And yes, this include doing things like deploying to several machines, stopping and starting services, updating the database schema and applying any data migration processes, and even doing rolling update, if this is a requirement.

Remember, automated.

And I'll leave you with just one final thought: Prayer should not be part of the steps in the deployment process.

Comments

V.
09/08/2008 01:02 AM by
V.

What kind of tool are you guys using to make automated deployment possible?

josh
09/08/2008 04:53 AM by
josh

outside of nant, I've never had a good deployment automation system. that's something I've always wanted. I wouldn't really consider a nant script a good automated deployment system, personally.

Andreas Öhlund
09/08/2008 06:22 AM by
Andreas Öhlund

We use TFSDeployer and it works quite ok (you need to be on TFS of cource)

http://www.codeplex.com/tfsdeployer

Adam
09/08/2008 07:58 AM by
Adam

Capistrano is a god send for deployments.

cap production deploy:migrations -- check out from SVN, run any pending migrations, restart the servers, done.

DannyT
09/08/2008 08:47 AM by
DannyT

I'd be interested in some references for achieving this (without TFS). I definitely fall into the never tried it category.

Ayende Rahien
09/08/2008 10:10 AM by
Ayende Rahien

Josh,

csc.exe can produce a really flexible build script

Paul
09/08/2008 05:37 PM by
Paul

Josh and others, I'm interested in why you wouldn't consider nant a good tool for automated deployment.

Tobin Harris
09/08/2008 07:03 PM by
Tobin Harris

+1 for Capistrano. For Mono at least :)

I'm not sure what it's Windows story is, if it even has one.

Louis
09/08/2008 07:54 PM by
Louis

Excellent points, especially about how this can be started in isolation. Deployment processes are something that can suffer from death by committee.

Max
09/08/2008 08:03 PM by
Max

Oren, what would you personally use to deploy a simple "ASP.Net"-type project? Considering that there are dev/qa/prod environments, single SQL box per environment, and a few web servers? Would you roll the deployment script from scratch in C#?

Ayende Rahien
09/08/2008 08:10 PM by
Ayende Rahien

depending on the ops environment.

Ideally, I would be able to do it by simple build script, something like:

-build

-create file app_offline.htm on srv1

  • push changes to srv1

-remove app_ofline from srv1

etc.

Jeff Brown
09/08/2008 08:24 PM by
Jeff Brown

At Ingenio we're using a bunch of batch files, VBScript and XML to do automated deployment of dozens of services, web sites, scheduled tasks, COM+ apps, reports, and other stuff across the web farm.

The hitch is that the system is getting long in the tooth (7-8 years old) and is a bit flaky. And yet... there still does not appear to be a decent commercial or open source tool that can handle stuff like this.

Capistrano seems fine for Rails apps on *ix... but there's not much out there for Windows.

I don't mind building a new tool but I wish I didn't have to for stuff like this which ought to fulfill a fairly universal need anyways. (Of course the devil is in the details and the assumptions you make up-front...)

Max
09/08/2008 08:44 PM by
Max

Yes, but how do you actually "push changes to srv1"? (The deployment script code is not running on srv1, and still needs to check for and create IIS virtual folders, install services, etc). Plus, IT nazis would want the exact same build to be installed first on QA and then on prod boxes. Yet somehow a bunch of parameters need to be different between QA and prod, some of which (like production passwords) they won't even let you check into SVN... I'm not saying that this can't be done, of course. But creating a fool-proof solution that works every time without prayer is not quite trivial, especially if you are starting from scratch (as in C#/BCL)

Stuart C
09/08/2008 08:53 PM by
Stuart C

We use a combination of msbuild, robocopy, SqlCompare API and Powershell 2. Msbuild and robocopy's uses are obvious. SqlCompareAPI we use to execute schema upgrades. Powershell 2 mainly for it's remoting abillity such as encrypting web.config and other config files.

Most of these tasks are msbuild tasks or custom scripts. I find it all a bit messy and tedious to put together, plus PS2 remoting is only supported on Vista and Win2008 at the moment.

I would love to see some better guidance and/or frameworks to help us out in this space...

Rhino.Deployment has a certain ring to it.. :)

Luc
09/09/2008 05:05 PM by
Luc

I just finishing an automated deployment at work.

We use the following comination of tools/ solutions: Subversion, Draco.NET, NAnt, MSBUILD, Wix3, DBScript, SQL Examiner.

The coolest part of the whole automated deployement and the hardest part is deployment of databases. We use only Micrtosoft SQL Server 2005 database at work.

First I use open source tool DBScript to get the whole database in separate scripts in Subversion. Then I made a simple tool to make a MDF from those scripts (HINT: create an empty mdf file with SQL Express and attach this file through SQL express and execute the scripts one by one to fill the structure of the new mdf file)

This simple tool is executed in the NAnt build script. Then during deployment I use the commandline tools of SQL Examiner to generate a diff sql script between the mdf file and the target database. And this diff script is executed by the same tool against the target database and voila database updated.

The only thing I have difficulties with is the whole WIX3 part. Its hard to find good documentation for it.

Robz
09/10/2008 12:02 AM by
Robz

And mine was a response to your original tools matter post. :D

http://ferventcoder.com/archive/2008/09/07/tools-matter-automated-builds--automated-deployments.aspx

Comments have been closed on this topic.