run build on cc.net if definite words are included to a commit log
cruisecontrol.net, msbuild, nunit, svn, webdriver
Solution
In the ccnet config, in the project, at the top of the tasks block:
<modificationWriter>
<filename>svn_mods.xml</filename>
<path>c:\modsdir</path>
</modificationWriter>
This will write the SVN modifications to a file.
Next in the tasks block:
<nant>
<executable>c:\path_to_nant</executable>
<buildFile>mybuildfile.build</buildFile>
<targetList>
<target>conditionally_run_nunit_tests</target>
</targetList>
</nant>
This will run a Nant task after the modificationwriter task.
In conditionally_run_nunit_tests, search the file c:\modsdir\svn_mods.xml for #runautotest. If you find it, run the tests. If you don't find it then do nothing. There are various ways to parse the mods file. You could use C# script to read the entire file into a string and then call Contains passing in #runautotest.
The below code is an example of using C# script in Nant. SearchFile opens a file, reads it into a string and checks if a value is in the string. It returns "yes" or "no". The below script is untested.
<property name="yesno" value="${ns::SearchFile("c:\modsdir\svn_mods.xml", "#runautotest")}"/>
<script language="c#" prefix="ns">
<references>
<include name="System"/>
<include name="System.IO"/>
</references>
<code>
<![CDATA[
[Function("SearchFile")]
public static string SearchFile(string filepath, string token)
{
System.IO.StreamReader myFile = new System.IO.StreamReader(filepath);
string myString = myFile.ReadToEnd();
myFile.Close();
if(myString.Contains(token)) return "yes";
else return "no";
}
]]>
</code>
</script>
Problem
I have system of: - svn - control version - cc.net - as ci server - msbuild - as a build system - nunit - for launch test - webdriver - for web-testing. Now my tests are run automatically after each commit. But i want that my test run if commit has comment #runautotest (or another). I investigated triggers of cc.net but its are for another goals. I try to found some information about cc.net parse logs but this was don't has positive result. What kind of ways i should use for resolve my issue?