Email reports from cruisecontrol? - testing

Is there a way to have cruisecontrol to email test result in through the config file? C:\Program Files\cruisecontrol\test-output\index.html
This is my current publish setting in the config.xml:
<publishers>
<currentbuildstatuspublisher file="${log.dir}/status.txt"/>
<htmlemail
buildresultsurl="http://${build.server}/buildresults/${project.name}"
subjectprefix="[CruiseControl] "
xsldir="${cruise.install.dir}/webapps/cruisecontrol/xsl"
css="${cruise.install.dir}/webapps/cruisecontrol/css/cruisecontrol.css"
logdir="${log.dir}"
mailhost="mailhost" defaultsuffix="#myemail.com" reportsuccess="always"
returnaddress="${return.email}"
>
<always address="${team.email}"/>
</htmlemail>
</publishers>

you should be able to include it using the fileMerge task, something like this:
<publishers>
<merge>
<files>
<file>C:\Project\test-output\emailable-report.html</file>
<file><!-- path --></file>
</files>
</merge>
</publishers>
Edit: Assuming the file is XML based...

Related

Build target tools path

I am currently packaging a nuget package for my code generator project and I have gotten so far as to include an executable into the tools directory and a build target into the process.
Partial from the nuspec
<files>
<file src="cgbr.targets" target="build\cgbr.targets" />
<file src="cgbr.json" target="content\cgbr.json" />
<file src="..\bin\CGbR.Lib.dll" target="lib\CGbR.Lib.dll" />
<file src="..\bin\cgbr.exe" target="tools\cgbr.exe" />
</files>
Content of the cgbr.targets file
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="BeforeBuild">
<Exec Command="cgbr.exe $(ProjectDir)"/>
</Target>
</Project>
Now when I install the package I see that it is included into the build process. Unfortunately the path to cgbr.exe is invalid and I am a little stuck. Of course I could use $(SolutionDir)packages\CGbR.0.3\tools\cgbr.exe but than I would have to modify it every time I change the version.
To clarify: I need the path to my packages tools path.
Edit: Found a related post
You probably want a relative path to the tool from the targets file. There are a number of predefined properties in msbuild. Perhaps the most useful for these scenarios is MSBuildThisFileDirectory which returns the full path to the directory of the current proj file. An example:
<Exec Command=""$(MSBuildThisFileDirectory)..\tools\cgbr.exe" "$(ProjectDir)""/>

Adding files to a zip using MSBuild ExtensionPack Zip creates entire file structure

I'm looking at MSBuild.Extensionpack.Compression.Zip to add a custom build step where I'd like to add some files to an existing .zip archive.
<ItemGroup>
<Files Include="$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder\*.xml">
</Files>
</ItemGroup>
<Message Text="#(Files)"></Message>
<MSBuild.ExtensionPack.Compression.Zip TaskAction="AddFiles"
CompressFiles="#(Files)" ZipFileName="$(MyZipArchive)"/>
When running this, the files are indeed added to the zip archive, but not into the root. Instead it creates a file hierarchy that corresponds to the path of my project
Projects/MyProject/SomeFolder/AnotherFolder/myfile.xml
Any thoughts on how I can get the myfile.xml inside the root of the .zip archive?
Sorry, I was getting to hasty. Just found the solution in the answer of this question.
The AddFiles action has an optional property RemoveRoot. Here you have to specify the string of the root you want to remove.
Final solution looks like this.
<ItemGroup>
<Files Include="$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder\*.xml">
</Files>
</ItemGroup>
<MSBuild.ExtensionPack.Compression.Zip TaskAction="AddFiles"
CompressFiles="#(Files)" ZipFileName="$(MyZipArchive)"
RemoveRoot=$(MSBuildProjectDirectory)\SomeFolder\AnotherFolder />

Executing all sql files in a folder with ant script (apply task)

I have a problem executing all SQL files in a folder with sqlplus command
I can run one file or first file with this code
<apply executable="sqlplus" dir="." parallel="false">
<!-- <arg value="-S" /> -->
<arg line="${db.user}/${db.pwd}#'${db.sid}'" />
<arg value="#${db.run.build.script}" /> this is working, which is for executing one file
<!-- <arg value="--e source" /> -->
<srcfile/>
<fileset dir="..\..\Documents\test\Database\SQL\common\test"
casesensitive="no" description="take all sql files">
<patternset>
<include name="**/*.sql" />
</patternset>
</fileset>
</apply>
; but cannot proceed further with other files
I have tried various options with apply task; but still not succeed; I thought the second file hasn't "#" in the beginning that causes the problem.
any help will be highly appreciated.
OK, first of all: I've never used sqlplus :-)
But based on the post I've seen here: http://www.zorbathegeek.com/161/run-multiple-sqlplus-queries-via-dos-batch-file.html I understood that it's a must to provide # as a prefix to path to all the files that should be considered.
I see there multiple options, based on restrictions:
First check if you can provide in command line multiple of your files like this:
sqlplus [login details] #C:/<your_path>/<file1>.sql #C:/<your_path>/<file1>.sql
depending if it's possible or not, you should later decide if you need to create 1 file containing all the filenames prefixed with # (as the example provided in the reffered site) or not
Now how to do the prepending? I think it should be simple, just try to use Ant's parhconvert described: http://ant.apache.org/manual/Tasks/pathconvert.html
<fileset dir="..\..\Documents\test\Database\SQL\common\test" id="sql.files">
<include name="**/*.sql"/>
</fileset>
<pathconvert pathsep=" " property="prefixed.sql.files" refid="sql.files">
<map from="c:/" to="#c:/"/>
</pathconvert>
(where you should replace c:/ with the string that your file paths start with. Moreover, if you will dump to file, pathsep=" " should be probably replaced with pathsep="\n" as there might be a need to have one file per line, but this needs test)
then depending on the options of all in one file or all files on cmd line, you:
either need to dump it to tmp file and run using this tmp file name
http://ant.apache.org/manual/Tasks/echo.html
In this case, the file should be later deleted
use property prefixed.sql.files directly in your apply arg value like:
<arg value="${prefixed.sql.files}" />

What in my CruiseControl.NET configuration is causing this exception?

In attempting to set up a build for a demo project I am working on, I received the following exception:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Documents and Settings\Administrator\Local Settings\Temp\1bea7440-959c-4dd4-89ad-05dcd00e369c\ThoughtWorks.CruiseControl.MsBuild.dll'
Question: What don't I have configured correctly?
Below is my task block from my ccnet.config file:
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\CCWorkingDirectory\DemoApplication</workingDirectory>
<projectFile>DemoApplication.sln</projectFile>
<!--<buildArgs>/noconsolelogger /v:quiet
/p:Configuration=Debug
/p:ReferencePath="C:\Program Files\NUnit 2.4.7\bin"
</buildArgs>-->
<targets>ReBuild</targets >
<timeout>600</timeout >
<!--<logger>c:\Program Files\CruiseControl.NET\server\Rodemeyer.MsBuildToCCNet.dll</logger >-->
</msbuild>
</tasks>
You need to include ThoughtWorks.CruiseControl.MsBuild.dll in the working directory of your application.
So you need to put ThoughtWorks.CruiseControl.MsBuild.dll in C:\CCWorkingDirectory\DemoApplication
Here's a link about the MSBuild tag.
You could alternatively include it in the logger tag like so:
<logger>
C:\Program Files\CruiseControl.NET\server\
ThoughtWorks.CruiseControl.MsBuild.dll
</logger>

Cruise Control.NET File Merge NUnit File - Getting XmlException

I am new to Cruise Control. I'm running a project where I use an MSBuild file to build my project. I'm using the NUNit task in the MSBuild Community Tasks project to run all of my unit tests and output an xml file with the test results with this command:
<NUnit Assemblies="#(OutputFiles)" WorkingDirectory="$(UnitTestResultsLocation)"
OutputXmlFile="$(UnitTestResultsLocation)\$(ProjectNameSpace).UnitTests.xml"
ToolPath="$(NUnitToolPath)"
ContinueOnError="true" />
This works great. Now I'm trying to get those results to show in the Cruise Control web dashboard by doing a file merge with this command:
<publishers>
<merge>
<file>C:\CC\Project1\Code\UnitTestResults\Project1TestResults.UnitTests.xml</file>
</merge>
</publishers>
When I do this, the build still completes, but I get an exception in the Cruise Control console, which also show in the log:
2009-09-03 13:44:57,310 [Project1:DEBUG] Exception: System.Xml.XmlException: Name cannot begin with the '.' character, hexadecimal value 0x2E. Line 837, position 36.
Am I going about this wrong? How can I get my NUnit test results into the Cruise Control dashboard?
Try
<merge>
<files>
<string>C:\CC\Project1\Code\UnitTestResults\Project1TestResults.UnitTests.xml</string>
</files>
</merge>
The following works for me, though I'm using NAnt to trigger NUnit, not MSBuild:
<publishers>
<merge>
<files>
<file>C:\Projects\SomeApp\CI\TestResult.xml</file>
</files>
</merge>
<xmllogger />
</publishers>