Cruisecontrol Publish command onfailure - cruisecontrol.net

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>

Related

Server Error in '/ccnet' Application

My CCTray says build is broken and on the server(http://172.25.165.10/ccnet/)
I get this error
Server Error in '/ccnet' Application.
Configuration Error
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<!-- This is your CruiseControl.NET Server Configuration file.
Add your projects below! -->
<project name="winapp"
description="demoproject showing a small config" queue="Q1">
<webURL>http://172.25.165.10/ccnet/</webURL>
<!-- specify a state folder to prevent CCNet from saving it in Program Files\CruiseControl.NET\server
programs may not standard write their data in it on windows Vista and up)
-->
<sourcecontrol type="svn">
<trunkUrl>https://citdevbox.arcade.local:8443/svn/cardwellR/trunk/winapp</trunkUrl>
<workingDirectory>c:\builds\winapp</workingDirectory>
<username>***</username>
<password>***</password>
</sourcecontrol>
<state type="state" directory="C:\CCNet\State" />
<!-- specify a artifactDirectory to prevent CCNet from saving it in Program Files\CruiseControl.NET\server
programs may not standard write their data in it on windows Vista and up)
-->
<artifactDirectory>C:\CCNet\BuildArtifacts\MyFirstProject</artifactDirectory>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\\v3.5\MSBuild.exe</executable>
<projectFile>C:\Builds\build\BootStrapper.msbuild</projectFile>
<buildArgs>/noconsolelogger /t:CTSx86;BuildZip /v:d</buildArgs>
<logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
<timeout>900</timeout>
</msbuild>
</tasks>
<triggers>
<!-- check the source control every X time for changes,
and run the tasks if changes are found -->
<intervalTrigger
name="continuous"
seconds="300"
buildCondition="IfModificationExists"
initialSeconds="5"/>
</triggers>
<publishers>
<xmllogger />
<artifactcleanup cleanUpMethod="KeepLastXBuilds"
cleanUpValue="50" />
</publishers>
</project>
</cruisecontrol>
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The root element must match the name of the section referencing the file, 'appSettings'
Source Error:
Line 1: cruisecontrol xmlns:cb="urn:ccnet.config.builder"
Source File: C:\Program Files (x86)\CruiseControl.NET\server\ccnet.config Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
You didn't post the content of your ccnet.config file which the error you are getting is complaining about. Lets start with the obvious. I would look to see if there is a typo in there, for example maybe a missing quote or something in the appSettings section. If you have the unmodified version revert back to that and see if your issue goes away and compare the unmodified with the modified.
There is an app called CCValidator which will tell you where the error is in your ccnet.config file. I suspect that is not where the problem is. It sounds like the error is in the ccservice.exe.config. Perhaps someone accidentally copied ccnet.config to ccservice.exe.config. The error may also be in your web dashboard's configuration.
I solved the issue by removing the build args tag.
</noconsolelogger /t:CTSx86;BuildZip /v:d>
My processor was 64 bit and I was using noconsolelogger /t:CTSx86 which is for a 32 bit processor. Anyway these were optional so I removed it worked fine.

How to integrate xUnit.net with CruiseControl.net

I have a continuous integration server that discovers and runs assemblies with NUnit tests. I would like to add some assemblies with xUnit.net tests to the mix. How would I do that?
Download xunit-build-xyzw.zip from xUnit.net on CodePlex and extract it to, for example, C:\Program Files\xUnit.net. Add this location to PATH environment variable
be sure to have no trailing semicolon
Modify your CC.NET *.build script to discover assemblies by convention, as outlined below
note that command line argument syntax no longer has equals sign
In C:\Program Files\CruiseControl.NET\server\ccnet.config, Merge XML files produced by NUnit runner and by xUnit.net runner, as outlined below
merging happens after build, irrespective of build status
be sure results of test run get deleted in the beginning of build script
Restart CC.NET
Download xUnitSummary.xsl from xUnit.net on GitHub and place it in C:\Program Files (x86)\CruiseControl.NET\WebDashboard\xsl
In C:\Program Files\CruiseControl.NET\WebDashboard\dashboard.config, modify buildPlugins element as outlined below
Restart IIS
Additional info:
CruiseControl.Net – Server Installation at Neal's Blog
Step 2:
<project default="RunTests_xUnit">
<target name="RunTests_xUnit" description="Runs the discovered xUnit.net unit tests" depends="someCompileStep">
<!-- Outer loop to search through a list of different locations -->
<!-- Folders to be searched should listed as a semicolon deliminated list in the 'in' attribute -->
<foreach item="String" in="${TestAssemblyOutputPath}" delim=" ;" property="testsPath">
<echo message="Searching for xUnit.net test suites in ${testsPath}" />
<!-- Inner loop to search for dlls containing unit tests -->
<foreach item="File" property="filename">
<in>
<items basedir="${testsPath}">
<!-- see http://nant.sourceforge.net/release/0.91/help/types/fileset.html for how to include or exclude specific files or file patterns -->
<!-- attempt to run tests in any dlls whose name ends with UnitTestSuite.dll' -->
<include name="**UnitTestSuite.dll" />
</items>
</in>
<do>
<property name="testDLLName" value="${path::get-file-name-without-extension(filename)}" />
<echo message="Testing ${testDLLName} with xUnit.net" />
<exec program="${xunit-console.exe}" failonerror="true" resultproperty="resultVal">
<arg line="${testsPath}\${testDLLName}.dll /xml ${xUnitTestLogsFolder}${testDLLName}-xUnitResults.xml" />
</exec>
<fail message="Failures reported in ${testDLLName}." failonerror="true" unless="${int::parse(resultVal)==0}" />
</do>
</foreach>
</foreach>
</target>
</project>
Step 3:
<publishers>
<merge>
<files>
<file>C:\logs-location\xUnitTestLogs\*UnitTestSuite-xUnitResults.xml</file>
<file>C:\logs-location\TestLogs\*Tests-Results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
</publishers>
Step 5:
<buildPlugins>
<buildReportBuildPlugin>
<xslFileNames>
...
<xslFile>xsl\xUnitSummary.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
...
<xslReportBuildPlugin description="xUnit.net Report" actionName="xUnitReport" xslFileName="xsl\xUnitSummary.xsl" />
...
</buildPlugins>

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>

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