
Stabilizing builds
January 4, 2010One challenge facing build managers is how to control the environment in which builds are performed. How to ensure that each repeated build uses the same sources, the same libraries, the same compilers, and so on. Only by ensuring all these elements can we truly claim to be able to reproduce a build reliably and only by controlling all these elements can we be certain that derived objects built previously are compatible with incremental builds.
Various solutions have been proposed to this conundrum, most of which involve tracking the complex relationships between source and derived objects. In recent years another somewhat simpler solution has presented itself. Instead of controlling all of the precondition factors individually, create one controlled environment and reuse this for each build. The potential flaw in this approach is that running a build will more often than not change the environment, and reconstructing the build environment is often difficult, time consuming and prone to error.
Virtual environments provide a perfect solution. Construct the build environment once as a virtual machine environment and then each build starts by restoring the virtual environment back to the initial condition. Source code (including the build scripts that direct the build) is stored in a separate repository and extracted to the build environment as normal. Derived objects (produced during a build) are held separate to the build environment so that they are not reset during the build.
There remains one potential problem when performing incremental builds. If your build relies on changes to the build environment to function properly, these changes will be discarded when the build environment is restored to its initial state. If, for example, your build registers objects with the Windows registry during the build, these items will not be registered at the start of the build so your build must be written to ensure these environmental changes are repeated even when the items themselves are not rebuilt.