Add the build number to websites automatically

I always add the build number to websites automatically in my continuous integration environment. This allows developers and testers to ensure which build they are testing.

Jenkins Build Number To review, my continuous integration system always does the following:

  1. Build all the code from a clean environment
  2. Report on code duplication
  3. Recreate the test database from scratch
  4. Deploy all services (including services and websites)
  5. Run all unit tests
  6. Report on unit test coverage

Automatically deploying services and websites has always been easy using installutil and msbuild, respectively.

I wrote a simple tool, JenkinsTitleUpdater which I run before the deployment step in my build system. This is included in the deploy step of the msbuild script.

The JenkinsTitleUpdater uses the HtmlAgilityPack. It allows XmlDocument-style navigation of HTML pages. This example updates the _Layout.cshtml page to append the Jenkins build number.

Source code and binaries are available here : JenkinsTitleUpdater.

Share this Post