Skip to content

Instantly share code, notes, and snippets.

@antifriz
Created January 11, 2021 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antifriz/3389fba0f24a19e8ec09b1bb68518ba4 to your computer and use it in GitHub Desktop.
Save antifriz/3389fba0f24a19e8ec09b1bb68518ba4 to your computer and use it in GitHub Desktop.
pytest/pylint/flake8/mypy to Jenkins xunit plugin converter (used with Custom tool type)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"
cdata-section-elements="system-out system-err failure"/>
<xsl:decimal-format decimal-separator="." grouping-separator=","/>
<xsl:template match="testsuites">
<testsuites>
<xsl:apply-templates select="testsuite"/>
</testsuites>
</xsl:template>
<xsl:template match="testsuite">
<testsuite>
<xsl:if test="@name">
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@tests">
<xsl:attribute name="tests">
<xsl:value-of select="@tests"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@errors">
<xsl:attribute name="errors">
<xsl:value-of select="@errors"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@failures">
<xsl:attribute name="failures">
<xsl:value-of select="@failures"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@skips">
<xsl:attribute name="skipped">
<xsl:value-of select="@skips"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@time">
<xsl:attribute name="time">
<xsl:value-of select="@time"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="testcase"/>
</testsuite>
</xsl:template>
<xsl:template match="testcase">
<testcase>
<xsl:if test="@classname">
<xsl:attribute name="classname">
<xsl:value-of select="../@name"></xsl:value-of><xsl:text>.</xsl:text><xsl:value-of select="@classname"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@name">
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@time">
<xsl:attribute name="time">
<xsl:value-of select="@time"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="error">
<xsl:copy-of select="error"/>
</xsl:if>
<xsl:if test="failure">
<xsl:copy-of select="failure"/>
</xsl:if>
</testcase>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment