We started using CruiseControl for .NET during the first phase of one of our new products currently under development and were very happy with the results. We basically had it set up to run one build script that would check out our source from StarTeam and run the unit tests, code coverage reports and the FXCop report whenever new code was checked in. This was fine for the first phase but we wanted to start the second phase by having a nightly build and a continuous build cycle going. The trick was we only wanted the source checkout and unit tests to run for the continuous build. For the nightly build we wanted a full set of unit tests, QA tests, code coverage reports and the FXCop report. This posed the first problem.
Before I continue I want to make it clear I am new to using CruiseControl so the solution I found may be a hack. I’m hoping either 1) it is a hack, I did a lot of work I didn’t need to do, and someone with more knowledge will point, laugh, and tell me how to really do this. Or 2) this is the only way to do it and the information will prove helpful to others.
After a short investigation I found the best way to do this would be to create two separate projects that use a trigger for the nightly build on a polling schedule and the continuous build on polling interval trigger. However, not long after I set up the two different projects I came across my second problem. Both projects were trying to check out the source code to the same location and StarTeam didn’t like it. In order to solve this problem I created two different source code working folders, one for the nightly build and one for the continuous build. Of course making this change required a change to my StarTeam checkout code because I was no longer checking out the source code to the working folder setup for the project in StarTeam. This change caused my third problem.
The third problem I faced was trying to get CruiseControl for .NET to understand it needed to look in a different working folder than what was defined in StarTeam whenever it did its compares. In order to solve this problem I took the drastic action of changing the source code for the Starteam.cs project file (See code changes below). In order to get the results I wanted I added a working folder property to the code so I could override the default folder set in StarTeam (This change was surprisingly easy to implement). After I made these changes I was able to set the working folder in the service config file and it worked perfectly.
Code Changes (changes in bold)
internal readonly static string HISTORY_COMMAND_FORMAT = "hist -nologo -x -is -rp \"{0}\" -filter IO -p \"{1}:{2}@{3}:{4}/{5}/{6}\" \"*\"";
internal readonly static string GET_SOURCE_COMMAND_FORMAT = "co -nologo -x -is -rp \"{0}\" -q -f NCO -p \"{1}:{2}@{3}:{4}/{5}/{6}\" \"*\"";
private string _workingFolder;
public StarTeam(): base(new StarTeamHistoryParser())
{
_executable = "stcmd.exe";
_host = "127.0.0.1";
_port = 49201;
_path = String.Empty;
_autoGetSource = false;
_workingFolder = String.Empty;
}
[ReflectorProperty("workingFolder",Required=false)]
public string WorkingFolder
{
get { return _workingFolder; }
set { _workingFolder = value; }
}
internal string BuildHistoryProcessArgs(DateTime from, DateTime to)
{
return string.Format(
HISTORY_COMMAND_FORMAT,
WorkingFolder,
Username,
Password,
Host,
Port,
Project,
Path);
}
internal string GetSourceProcessArgs()
{
return string.Format(
GET_SOURCE_COMMAND_FORMAT,
WorkingFolder,
Username,
Password,
Host,
Port,
Project,
Path);
}
posted @ Wednesday, December 15, 2004 5:37 PM