Search code examples
htmlxmljunitjenkins

How to add a href links in <system-out> or <failure> tags in Jenkins/JUNIT xml


I have integrated Jenkins to C unit test library and I am parsing the output and generating XML in the schema that the jenkins understands.

while generating the xml output, I just show the gist of the errors reported, and I would like to create a link to where the actual logs are located so that the user can click on teh link in jenkins to view the actual file.

I am unable to add the HTML tags under this XML. The Jenkins turns them into encoded <.. and makes my link useless. I even try to use . But I am still not able to get it.

Has anyone tried creating a link under jenkins report. Any help is much appreciated.

The following have not worked.

1.<failure> blah.. blah.. (my brief log summary)
     <a href="www.stackoverflow.com">ERROR</a>
  </failure>

2. <failure> blah.. blah.. (my brief log summary)
     &lt;a href=\quot;www.stackoverflow.com\quot;&gt; ERROR &lt;/a&gt;
   </failure>

3. <failure>
     <![CDATA[ <a href="www.stackoverflow.com">ERROR</a>]]>
   </failure>

4. <failure>
      //CDATA with encoded &gt; &lt;

Thanks in advance


Solution

  • Out testing framework has pluggable reporting modules - a call from a test generates output for all 'registered' modules. Among those are JUnit, HTML, and SQL.

    The first one generates JUnit reports that can be immediately processed by Jenkins to decide if the build is stable or not, draw the nice trend graph, etc.

    The second one generates the error log in a human-readable form. Over time it has been embellished with all kinds of bells and whistles - different colors for different kinds of status, shrinkable/expandable sections, and so on. A link to this log is displayed among the artifacts for a build.

    SQL logger uploads test results into a database for eternal storage and heavy-duty analysis.