CruiseControl.NET for Running Static Analysis – Part 2

Saturday, October 14, 2006 – 6:34 PM

Writing a Custom CruiseControl.NET On Idle Trigger

So the other day I figured out how to hook up CCMetrics output alongside FxCop to get CruiseControl.NET doing some static analysis. As promised this covers how to configure the CC.NET service to run integrations when the machine is idle.

The obvious approach is to write a custom trigger and the CC.NET documentation covers this but not in very much detail. It turns out to be pretty straightforward.

Create a .NET assembly project and change the assembly name to match the pattern ccnet.*.plugin.dll. If copied into the CruiseControl.NET\server folder the CC.NET server will load it automatically. The assembly should contain a class that implements ITrigger and is decorated with the appropriate NetReflector attributes.


using ThoughtWorks.CruiseControl.Core.Util;
using ThoughtWorks.CruiseControl.Core.Triggers;
using ThoughtWorks.CruiseControl.Remote;namespace AdeMiller.CruiseControl.Triggers
public sealed class IdleTrigger : ITrigger

The ITrigger interface itself is very simple:

public interface ITrigger
    DateTime NextBuild { get; }
    IntegrationRequest Fire();
    void IntegrationCompleted();

The Fire method gets called at frequent intervals and its upto your code to figure out if it should return a non-null IntegrationRequest. All my trigger does is keep a rolling average of the current processor CPU usage and fires off a build if the usage is less than a specified value.

You can download the sample code for the IdleTrigger here.

  1. 1 Trackback(s)

  2. Nov 21, 2007: #2872 » Blog Archive » Tools for personal coding projects

Sorry, comments for this entry are closed at this time.