How to output the project properties to the build XML logs so that they can be used in XSL files? - cruisecontrol.net

We use cruisecontrol for our daily automatic tests. We use the JUnit framework. For every case, we have an output file other than the log file of the junit case. We add the output files to the artifact directory of the project when the build completes. We use the built-in XSL file "unittests.xsl" to publish the email results.
Recently, I want to modify the xsl file "unittests.xsl" to add a hyperlink to the output file for every case. Here is what I tried at the very beginning:
<td class="unittests-data" width="300">
<xsl:value-of select="..//#name"/>
</td>
The problem here is, the url of the output file can work when opening the result page using the web browser; but the url is incorrect in the result mail. In the mail, the url is concated as:
http://localhost:18080/cruisecontrol/buildresults/artifacts/...
But what I want is:
http://localhost:18080/cruisecontrol/artifacts/...
So I am thinking of another way to solve this. My thought was to output a property of the root url to the project logs so that the XSL file can get its value like this:
<xsl:variable name="urlroot" select="/cruisecontrol/info/property[#name='urlroot']/#value"/>
<td class="unittests-data" width="300">
<xsl:value-of select="..//#name"/>
</td>
The problem here is, the properties of the project (defined in config.xml) are not outputed to the project logs. So that I can not do it this way.
Is there any other way to achieve this? Thanks in advance.

Create a xml file to hold the properties you need to have in the CC publishing phase
Fill out the xml file with the properties during the build
Copy the file to the CC merge directory at the end of the build
Target the property values in the xsl transformer
If you echo the properties to the CC log during the build then they end up in an unpredictable location in the CC log. A reliable way is to create an xml file specifically for the stuff you need and merge it into the log at the end. Now you may reliably target the values in the xsl.

You can simply pass the properties to some antbuilde and echo them. Then when you merge your log files the property values will be in it.

Related

When using Gauge for UI Automation is there a way to get all screenshots in the same folder as the report

I am using the Gauge framework for UI Automation.
My hope is that I am able somehow to write screenshots to the folder being made to contain the html report for an execution. The trick is that the folder and its contents for a report are not made until after execution completes so I can't write screenshots inside the reports folder as I am taking them during my tests.
Currently the screenshots that I take are written to a folder in the reports folder (root level) of the project. When trying to copy the entire html report to another location I have to also move the screenshots and then have to manually manage the screenshots in that extra screenshots folder as I delete old reports. There are a lot of after the fact steps that I could do but was hoping for a simpler solution.
I am hoping that I was missing something and there was a way to write the screenshots into each reports folder (when reports are not being overwritten) so that I don't have to mangage (move/delete) the screenshots separately and so that the links in the report to the screenshots stay consistent.
Screenshots in gauge's html-report are embedded inside the html as a base64 encoded string. So they currently don't exist as a separate file that you can manipulate.
Some options for your use case:
1) Implement a Custom Screenshot Grabber and intercept the screenshot, save it to any location you like.
2) build a custom reporting plugin (ex, build on this seed example) and collect the screenshots independent of the html report.
If you do not want the reports to be overwritten, you can set overwrite_reports=false in your properties file. See ref.
Note that you can also change the html-report's theme if you want a different report structure.

How to Read in multiple CSV files from an XSLT file and output a single XML file

I plan to use Saxon for an XSLT problem. I need to run my program on a schedule. When it runs it needs to select all CSV files from a directory. The number of files can be random but once processed they are cleared from the folder by another process. Originally there was only one CSV file with a fixed name so referencing it in the XSLT wasn’t a problem. I could also programmatically set the filename at runtime so all was working well. My XSLT now needs to know about all the files so I can output a single XML. I’m not sure if I can pass in a file path and let the XSLT read in all the files at that location? Is there a command to do this or is there a better way to do this? Remember I don’t know how many CSV files will be in the folder when the XSLT is run.
See www.saxonica.com/documentation/sourcedocs/intro.xml, you can use the collection function to read in files from a directory e.g.
<xsl:for-each select="collection('file:///C:/dir/subdir?select=*.csv;unparsed=yes')/tokenize(., '\n')">
<line><xsl:value-of select="."/></line>
</xsl:for-each>

Sharepoint Content Query Webpart untrusted xsl file

I have created a custom xsl file for the Content Query Webpart. I assigned the path of the xsl file to the property "MainXsl" of the CQW. After I put the CQW to a sub sitecollection, it show me the following message: "The web part references an untrusted XSL file. Only XSL files contained in this site's Style Library may be referenced."
I have checked up, there is my xsl file in the sub sitecollection (Style Library/XSL Style Sheets) and is published.
Please tell me how to solve this problem?
Bit of thread necromancy here, but as this is one of the top Google result for the error message...
I was getting this error even with the XSL file in the site collection's Style Library. To fix, when you reference the XSL file (in my case in the .webpart file), use server-relative path, eg. /sites/[site name]/Style Library/[stylesheet].xsl and all will be well!
EDIT: From #MBentley's comment, you can also use URL tokens, such as ~site/Style Library/[stylesheet].xsl to avoid having to use the absolute URL.

CruiseControl.Net - inclusion of html report? (I get 'Unable to find file')

I have build that produces a (NCover 3.4 Summary) html report.
I'd like to configure the Dashboard to show the html report.
The report is produced perfectly in working folder during the build - my problem is referencing the report from the Dashboard. Should I do something to store it from working folder into the 'cc.net build records'? I don't really understand the inner workings there...
My use of plugin in the Dashboard.config is shown below. I don't know what I should use actionName for and have left it with value from documentation.
The link in CC.Net resolves as: http://DummyServerName/ccnet/server/local/project/DummyProject/build/log20101221100723Lbuild.2.0.0.176.xml/viewReport.aspx
Thanks for any comments,
Anders, Denmark
<htmlReportPlugin description="NCover Summary" actionName="viewReport" htmlFileName="coverage_summary.html" />
From the CCNET Documentation [1] :
This plug-in can display any file that
is in the build folder under artefacts
folder for the project. It cannot
display files from any other location
(for security reasons). Files can be
published to a build folder using the
File Merge Task. This will
automatically generate the correct
folder structure for the HTML reports.
Either way, you can generate an xml report, merge it into the ccnet log and use an xsl to display it in the dashboard/emails.[2]
[1] http://build.nauck-it.de/doc/CCNET/HTML%20Report%20Plugin.html
[2] http://docs.ncover.com/how-to/continuous-integration/cruisecontrol-net/

Making a custom report with ccnet

So I have my output that I used the merge task to put into ccnet.
Now what I need to do is come up with my own custom xsl and output the data.
Any ideas on where there maybe a tutorial on how to do this?
For example what plugin do I need to use? Can I create my own? What does action name do?
<xslReportBuildPlugin description="MSBuild Output" actionName="MSBuildOutputBuildPlugin" xslFileName="xsl\msbuild.xsl" />
in your cruise control folder:
CruiseControl.NET\webdashboard\xsl
Copy any existing xsl (preferably one that is close to what you already want or in a format you like). you could start an xsl file from scratch also.
edit it to what you want it to be with your own file name.
I copied the msbuild.xsl to BMsBuild.xsl and made my changes.
then in dashboard.config
<xslReportBuildPlugin description="BBuildReport" actionName="BBuildReport" xslFileName="xsl\Bmsbuild.xsl"></xslReportBuildPlugin>
Description: what title you want it to have on the webdashboard link
actionName: a unique name that will be used to generate a URL for that xsl/report
xslFileName: the path to the xsl usually just xsl[your xsl file name].xsl
That's the easiest way. The file is nearly entirely xsl so there's not really anything special you need to do or know. Except that the xsl is going to target the merged xml file from whatever you have in the publishers xml logger tag in your ccnet.config
<publishers>
<statistics/>
<xmllogger logDir="D:\Projects\TFS\Main\BuildProcess\logs\ServiceBuilds" />
</publishers>

Resources