BOOKS DEEP-READ · CONTINUOUS DELIVERY · CH 6

Build and Deployment Scripting

Continuous Delivery · Ch 6 · Jez Humble & David Farley · 2010

中文 →

What is this chapter about?

The app on your phone updates every week or so. Between the code an engineer finished and the working version on your device sits a chain of actions: compile, package, copy to servers, adjust configuration, restart. Chapter 6 of Continuous Delivery is about how that chain should be written as scripts — not a few commands typed from memory, but something written the way you write real product code.

An analogy first

Think of a release as cooking. Manual deployment is a chef improvising: an extra spoon of salt today, a burner left on tomorrow. Scripting it means writing the recipe down and letting a machine follow it. But this chapter goes further: the recipe should not live on a sticky note on the fridge — scribbled ad hoc, one per kitchen, messier with every edit. It should be maintained like a published work: versioned, reviewed, and traceable back to the edition that went wrong.

A true story first

In August 2012 the US brokerage Knight Capital rolled out new code by hand to eight production servers and missed one. Dormant old code on that machine was woken up by a repurposed switch, fired off bad orders, and in roughly 45 minutes burned more than $460 million — effectively ending the firm. The root cause is not exotic: deployment was done by a person, machine by machine, with nothing guaranteeing the eight were identical.

Three words that carry the chapter

One, the same script. Development, test, production — all run the same deployment script, and the differences between environments live only in an external configuration file. Once each environment gets its own script, they drift apart, and the thing you rehearsed twenty times in test is not the code that runs in production.

Two, run it as often as you like. A good script does not say "do these 12 steps"; it says "make sure it ends up looking like this" — skip what is already installed, fix what is installed wrong. So when it dies halfway, you just run it again instead of cleaning up by hand first.

Three, layers. Split "install the OS and middleware", "place the application", "apply configuration" and "migrate data" into four separate scripts, because they change at wildly different rates: configuration might change three times a day, the OS once a year. Fused together, changing one config line means reinstalling middleware.

Where to start

Don't try to script everything at once. The chapter's advice is practical: start with the step that hurts most — whatever part of every release you dread and keep getting wrong — script that, then grow outward from it.

And the cost is real: scripting is not free. These scripts have their own bugs and need their own maintenance; you are now carrying another codebase. It still pays, because errors in manual deployment never show up in the test environment — only in production.

One thing to remember

Writing deployment down as a script is not enough. Every environment must share the same script (differences live in configuration), running it twice must change nothing, and it must be treated like production code: in version control, reviewed, refactorable.

Want the two schools of build tools, how idempotence actually works, and the comparison tables? → Switch to the deep read