Jenkins FxCop xml report view as a HTML format in Windows.

This topic about how I Solved convert XML file which is result of FxCop (Code Analyse Tool) to HTML in Jenkins and publish it as Report.

I recently installed FxCop  (Code Analysis Tool) and FxCop Runner plugin for Jenkins. Everything was ok, I got report file as XML format for my projects within Jenkins, but unfortunately, I didn’t found and plugin for view xml file within Jenkins as HTML.

So how I solved this problem:

I created simple console application in C# for converting xml+xsl to HTML with below code and connected it with Jenkins:

using System;
using System.IO;
using System.Xml.Xsl;

namespace XmlToHtml
 class Program
 static void Main(string[] args)
 if (args.Length < 3)
 Console.WriteLine("Usage: xml2html.exe xlsfile.xls xmlfile.xml output.html");
 if (!File.Exists(args[0]) || !File.Exists(args[1]))
 Console.WriteLine(args[0] + " or " + args[1] + " doesn't exist");
 XslCompiledTransform xsl = new XslCompiledTransform();
 String outputFile = args[2];
 xsl.Transform(args[1], args[2]);

if (File.Exists(args[2])) Console.WriteLine(args[2] + " successfully created!");
 else Console.WriteLine("Couldn't create " + args[2]);

You may download .exe file from here

Save it on your disk as C:\Program Files (x86)\xmltohtml\xmltohtml.exe

In Jenkins, project setting page we should do Add build step > FxCop exec as and fill input like below:

P.S If you don’t see any option in FxCop Name section go to the Manage Jenkins > Global Tool Configuration > FxCop > FxCop installations add Path to the FxCopCmd.exe

Assembly FIle should be .dll file which you want analyse

Output xml is for saving xml report file. You may fill it “fxcop/result.xml”

Then you should add another step for converting xml to html.

So, Click Add build step > Execute Windows batch command and type below

“C:\Program Files (x86)\xmltohtml\xmltohtml.exe” “C:\Program Files (x86)\Microsoft Fxcop 10.0\Xml\CodeAnalysisReport.xsl” “fxcop/result.xml” “fxcop/result.html”

As you see, I call xmltohtml.exe file, then pass 3 parameters to it, first parameter is xsl file which is located in Microsoft Fxcop 10.0\Xml\CodeAnalysisReport.xsl , second parameter is xml file which saved in previous step by FxCop, and third parameter is output file which will be saved as HTML.

Now we may add Add post-build action > Publish HTML reports in Post-build Actions section as below:


After succesfull build, you’ll see FxCop Result in your project page as below:

After clicking to FxCop Result page you should see  similar to below page:P.S If page in your browser not correctly view and javascript functions not properly works (Collapse and expand) it is related to Java security that doesn’t allow inline  style and javascript functionalities, for solve this problem I  run jenkins.war as below format:

java -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts; style-src 'unsafe-inline' *;script-src 'unsafe-inline' *;" -jar jenkins.war

It worked for me.

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published.