Cruise control - adding diagnostic logging - cruisecontrol.net

In Cruise control is there a way to log the description for a test step?
<exec>
<executable>$(cmd)</executable>
<baseDirectory>bin\$(bit)\Release</baseDirectory>
<buildArgs>/C del /Q /F /S *.*</buildArgs>
<description>Cleaning up the release directory</description>
</exec>
I notice the description does not end up in our log file?
Is there some other way to do this?

CruiseControl includes the details/specification of the task before any of the output; such as:
...
<buildresults>
<task>
<buildArgs>/c "echo hello"</buildArgs>
<buildTimeoutSeconds>1800</buildTimeoutSeconds>
<baseDirectory>c:\</baseDirectory>
<description>description</description>
<dynamicValues/>
<environment/>
<executable>c:\windows\system32\cmd.exe</executable>
<priority>Normal</priority>
<successExitCodes/>
</task>
<message>hello</message>
...
<buildresults>
...
This also includes the description of the task.
If the task fails, I believe the the exception text is included as text within the buildresults node

Related

Get the CCNetBuildDate in NAnt parallel tasks

In a cruise control configuration file, I use a set of parallel tasks to call some NAnt targets. I noticed that the CC system parameters (like CCNetBuildDate) are not pushed to the NAnt scripts, while they are pushed when I remove the parallel flag. How can I push the CCNetBuildDate information to my parallel tasks?
When I tested this (1.5) I got 0001-01-01 for CCNetBuildDate.
Until this bug is fixed you could save the correct settings before executing the parallel tasks. As you can not override properties passed on the command line you would have to change their names or use <exec> to call nant directly:
<nant>
<buildFile>SaveCCNetParameters.build</buildFile>
</nant>
<parallel>
<tasks>
<exec>
<executable>$(NAntExePath)</executable>
<buildArgs>-buildfile:Build1.build #CCNetBuildParameters</buildArgs>
</exec>
<exec>
<executable>$(NAntExePath)</executable>
<buildArgs>-buildfile:Build2.build #CCNetBuildParameters</buildArgs>
</exec>
</tasks>
</parallel>
where CCNetBuildParameters is a file looking similar to:
-DCCNetBuildDate=2012-11-10
-DCCNetBuildTime=12:12:12
-DCCNetLabel=123
[...]

Cruise Control parsing "!" character in NAnt file

I have Cruise Control configured with a task to run a NAnt script, which runs an MSTest suite. MSTest allows me to specify test categories so I want to specify "!Integration" (which means "don't run Integration tests"). My Nant script successfully runs when I run it from the command line, but when Cruise runs it, the "!Integration" directive is being garbled -- the Cruise output suggests its inserting a line break after the '!' character. The result is that all my tests run, including integration tests.
Extract from ccnet.config:
<tasks>
<nant>
<executable>C:\nant\bin\nant.exe</executable>
<baseDirectory>C:\MyProject\BuildDirectory</baseDirectory>
<buildFile>MyProject.build</buildFile>
<targetList>
<target>CIServerBuild</target>
</targetList>
</nant>
</tasks>
Extract from MyProject.build:
<target name="CIServerBuild">
:
<call target="RunUnitTests" />
</target>
<target name="RunUnitTests">
<property name="TestCategories" value="!Integration" />
<call target="RunMSTest" failonerror="true"/>
</target>
<target name="RunMSTest">
<call target="BuildListOfTestContainers" failonerror="true"/>
<exec program="${MSTest.exe}"
commandline=" /category:"${TestCategories}" ${TestContainers} /resultsfile:${MSTest.ResultsFile} /nologo "
/>
</target>
Extract from Cruise output:
[exec] Starting 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe ( /category:"!
Integration" /testcontainer:C:\TaxWise\BuildDirectory\TaxWise\TaxWise.Data.Tests\bin\Debug\TaxWise.Data.Tests.dll /testcontainer:C:\TaxWise\BuildDirectory\TaxWise\TaxWise.Domain.Tests\bin\Debug\TaxWise.Domain.Tests.dll /testcontainer:C:\TaxWise\BuildDirectory\TaxWise\TaxWise.Infrastructure.Tests\bin\Debug\TaxWise.Infrastructure.Tests.dll /resultsfile:.\TestResults\UnitTests.trx /nologo )'
in 'C:\TaxWise\BuildDirectory'
I have tried replacing the '!' character with
'!'
but that made no difference.
Any ideas, anyone?
I suggest splitting the commandline attribute in the exec task into Nant arg elements.
http://nant.sourceforge.net/release/0.85/help/tasks/exec.html
You'll have more flexibility and the readability will increase.
Yes, perhaps it is not caused by CC. Try setting verbose="True" on the <exec> task and check the raw build protocol. Remember what you see on the report page is not the exact output (typically subject to line-wrap and coalescing whitespaces).
Maybe it depends on from where you run the script, a hidden dependency on a build property or different environment variables. You can check the latter using <exec program="cmd.exe" commandline="/c set" />. For the properties you can use the following script:
<script language="C#" prefix="util" verbose="true">
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
foreach (DictionaryEntry entry in new System.Collections.SortedList(project.Properties) )
Console.WriteLine("{0}={1}", entry.Key, entry.Value);
}
]]>
</code>
</script>

Cruisecontrol Publish command onfailure

I've got a problem publishing my current Project status.
Mapping:
<publishers>
<xmllogger /><!-- Log For WebDashboard ##Do not remove##-->
<email>
...
</email>
<onfailure>
<exec>
<executable>echo ERROR > logs/status.txt</executable>
</exec>
</onfailure>
</publishers>
When i want to start my Service i get the following message:
ThoughtWorks.CruiseControl.Core.Config.ConfigurationException:
Unable to instantiate CruiseControl projects from configuration document.
Configuration document is likely missing Xml nodes required for properly populating CruiseControl configuration.
Unable to load array item 'onfailure' - Cannot convert from type System.String to ThoughtWorks.CruiseControl.Core.ITask for object with value: "echo ERROR > logs/status.txt"
Does anyone know what that message means?
Thanks in anticipation
Alex
Are you using CruiseControl or CruiseControl.NET?
If CC.NET, then the "onfailure" node does not exist. Instead you should use the Conditionnal Publisher[1] like this :
<conditionalPublisher>
<conditions>
<condition>Failure</condition>
</conditions>
<publishers>
<exec>
<executable>echo ERROR > logs/status.txt</executable>
</exec>
</publishers>
</conditionalPublisher>
You may also need to encapsulate your echo task in a cmd invokation :
<exec>
<executable>cmd.exe</executable>
<buildArgs>/c "echo ERROR > logs\status.txt"</buildArgs>
</exec>
[1] http://ccnetlive.thoughtworks.com/ccnet/doc/CCNET/Conditional%20Publisher.html
From the documentation, it looks like <executable> has to be the name of the executable and the arguments must be passed in <buildArgs>. So something like this may do the trick.
<exec>
<executable>echo</executable>
<buildArgs>ERROR > logs/status.txt</buildArgs>
</exec>

How to commit into TortoiseSVN using cruise control config file

hi all,
can any one tell how to commit into
tortoisesvn using cruise control
config file. I am getting an error
"C:*****\Documentation\trunk\dotnet\svn"
is not executable or it may not exist.
here's the config part...
<workingDirectory>C:\*****\Documentation\trunk\dotnet\</workingDirectory>
<category>Individual Solutions</category>
<modificationDelaySeconds>10</modificationDelaySeconds>
<sourcecontrol type="svn">
<trunkUrl>******* svn url *********</trunkUrl>
<username> unname </username>
<password> pwd </password>
<autoGetSource>true</autoGetSource>
</sourcecontrol>
<tasks>
<exec>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
<successExitCodes>0</successExitCodes>
</exec>
<exec>
<executable>iisreset</executable>
<buildArgs>/stop</buildArgs>
</exec>
<exec>
<executable>c:\Program Files\TortoiseSVN\bin\TortoiseProc.exe /command:commit /path:"C:\*****\Documentation\trunk\dotnet\"</executable>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
<successExitCodes>0</successExitCodes>
<description>checkin shared content...</description>
</exec>
<exec>
<executable>iisreset</executable>
<buildArgs>/start</buildArgs>
</exec>
</tasks>
</project>
Thank you all,
There's a few things:
You want to pass the command-line arguments to in the <buildArgs> element, not as part of the <executable> element (like you've done for the "issreset" command, for example).
Why are you checking stuff in after every build? The way you seem to have things set up here, it's just going to go into an infinite loop, building then checking in and building again (because it detected a new check-in). Generally, you don't check build outputs into your repository.

Getting MSTest output to show in CruiseControl.Net

I currently have our build server set up with CruiseControl.Net running a build using MSBuild and then running unit tests using MSTest. The problem is I can't see the output of the unit tests in CC - I know they are being run because I can get the build to fail if I commit a failing test.
I have followed the online guides from http://blogs.blackmarble.co.uk/blogs/bm-bloggers/archive/2006/06/14/5255.aspx and http://www.softwarepassion.com/?p=89 but still having no luck.
My ccnet.config file contains
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\CCBuilds</workingDirectory>
<projectFile>Application.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
<exec>
<executable>deleteTestLog.bat</executable>
<baseDirectory>C:\CCBuilds</baseDirectory>
<buildArgs></buildArgs>
<buildTimeoutSeconds>30</buildTimeoutSeconds>
</exec>
<exec>
<executable>C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe</executable>
<baseDirectory>C:\CCBuilds</baseDirectory>
<buildArgs>/testcontainer:UnitTests\bin\Debug\UnitTests.dll /runconfig:localtestrun.Testrunconfig /resultsfile:testResults.trx</buildArgs>
<buildTimeoutSeconds>30</buildTimeoutSeconds>
</exec>
</tasks>
<publishers>
<merge>
<files>
<file>testResults.trx</file>
</files>
</merge>
<xmllogger logDir="C:\Program Files\CruiseControl.NET\server\Checkin Build\Artifacts\buildlogs" />
</publishers>
The log file in C:\Program Files\CruiseControl.NET\server\Checkin Build\Artifacts\buildlogs contains the unit test results, have I missed any steps?
i made the following changes to get MSTest results output to be shown in CruiseControl.NET
1) For Dashboard - in dashboard.config added a reference to the Mstest 2008 xsl file under buildReportBuildPlugin
<xslFile>xsl\MsTestReport2008.xsl</xslFile>
2) For email - in ccservice.exe.config added the reference to the same xsl file under xslFiles section
<file name="xsl\MsTestSummary2008.xsl"/>
Did you configure your web dashboard with the correct xsl to format the outputs? There are two different versions of the XSL's (Summary and Report) for VSTS 2005 and 2008 as Microsoft changed the XML output drastically between the two versions. The changes were very good, just breaking changes.
For the Dashboard, I think you need to add the MSTest Summary in the xlsFiles, but add the MSTest Report build report plugin. That is,
<buildReportBuildPlugin>
<xslFileNames>
<xslFile>xsl\MsTestSummary2008.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
<xslReportBuildPlugin description="MSTest Report" actionName="MSTESTReport" xslFileName="xsl\MsTestReport2008.xsl" />
</buildPlugins>
I tried adding MSTestReport on both but it didn't work, but the setting above did. Hope that helps...

Resources