Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-56510

Provide generic issue parser for custom tools

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      5.0.0 (analysis-model and warnings-ng)

      Description

      I have a handful of custom tools to generate custom reports on my code base and/or the compiled results. Right now I am abusing the output format of PMD to get close to the output I want. However, it would be nice if I could generate a file that mapped directly to the fields used by the plugin.

      This might also be useful for people who do not have admin access to write groovy parsers. They could do some local analysis, then generate this file format.

      Current Serialization of an Issue instance using XStream:

      <?xml version="1.1" encoding="UTF-8"?>
      <issue>
        <category>category</category>
        <type>type</type>
        <severity>HIGH</severity>
        <message>message</message>
        <lineStart>1</lineStart>
        <lineEnd>2</lineEnd>
        <columnStart>3</columnStart>
        <columnEnd>4</columnEnd>
        <lineRanges>
          <lineRange>
            <start>5</start>
            <end>6</end>
          </lineRange>
        </lineRanges>
        <id>63d61b1f-0cac-4e31-8bb9-f390ed1acfe8</id>
        <description>description</description>
        <reference>reference</reference>
        <origin>origin</origin>
        <moduleName>module-name</moduleName>
        <packageName>package-name</packageName>
        <fileName>file-name</fileName>
        <fingerprint>fingerprint</fingerprint>
      </issue>
      

       
      Current Serialization of a Report instance using XStream:

      <?xml version="1.1" encoding="UTF-8"?>
      <analysisReport>
        <elements class="linked-hash-set">
          <issue>
            <category>category</category>
            <type>type</type>
            <severity>HIGH</severity>
            <message>1</message>
            <lineStart>1</lineStart>
            <lineEnd>2</lineEnd>
            <columnStart>3</columnStart>
            <columnEnd>4</columnEnd>
            <lineRanges>
              <lineRange>
                <start>5</start>
                <end>6</end>
              </lineRange>
            </lineRanges>
            <id>c3b984a3-7f67-4332-953b-27d3943f232c</id>
            <description>description</description>
            <reference>reference</reference>
            <origin>origin</origin>
            <moduleName>module-name</moduleName>
            <packageName>package-name</packageName>
            <fileName>file-name</fileName>
            <fingerprint>fingerprint</fingerprint>
          </issue>
          <issue>
            <category>category</category>
            <type>type</type>
            <severity reference="../../issue/severity"/>
            <message>2</message>
            <lineStart>1</lineStart>
            <lineEnd>2</lineEnd>
            <columnStart>3</columnStart>
            <columnEnd>4</columnEnd>
            <lineRanges>
              <lineRange>
                <start>5</start>
                <end>6</end>
              </lineRange>
            </lineRanges>
            <id>fbf2fee0-292f-4991-bd06-d8c5b13ace93</id>
            <description>description</description>
            <reference>reference</reference>
            <origin>origin</origin>
            <moduleName>module-name</moduleName>
            <packageName>package-name</packageName>
            <fileName>file-name</fileName>
            <fingerprint>fingerprint</fingerprint>
          </issue>
        </elements>
        <infoMessages>
          <string>info</string>
        </infoMessages>
        <errorMessages>
          <string>error</string>
        </errorMessages>
        <duplicatesSize>0</duplicatesSize>
      </analysisReport>
      

       

        Attachments

          Issue Links

            Activity

            Hide
            drulli Ulli Hafner added a comment - - edited

            This is a good idea! If the parser would be part of warnings-ng (and not analysis-model) then Jenkins XML reading logic (XStream) could be used, see AnalysisResult.java.

            Show
            drulli Ulli Hafner added a comment - - edited This is a good idea! If the parser would be part of warnings-ng (and not analysis-model) then Jenkins XML reading logic (XStream) could be used, see AnalysisResult.java .
            Hide
            derrickgw Derrick Gibelyou added a comment -

            That is an interesting idea.

             Could that cause problems since it would be de-serializing XML generated by a different tool?  I don't have any experience with XStream.  Does it handle missing fields well?  I wouldn't expect the external tools to populate all the possible fields of an issue.

            Show
            derrickgw Derrick Gibelyou added a comment - That is an interesting idea.  Could that cause problems since it would be de-serializing XML generated by a different tool?  I don't have any experience with XStream.  Does it handle missing fields well?  I wouldn't expect the external tools to populate all the possible fields of an issue.
            Hide
            drulli Ulli Hafner added a comment -

            Yes, it handles missing fields quite well. And the serialization fallbacks are under our control, see https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/main/java/io/jenkins/plugins/analysis/core/model/IssueStream.java.

            Show
            drulli Ulli Hafner added a comment - Yes, it handles missing fields quite well. And the serialization fallbacks are under our control, see https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/main/java/io/jenkins/plugins/analysis/core/model/IssueStream.java .
            Hide
            hobbyte Raphael Furch added a comment -

            Ulli Hafner  I don't know exactly what to do here. Can you give me a hint please? 

            Show
            hobbyte Raphael Furch added a comment - Ulli Hafner   I don't know exactly what to do here. Can you give me a hint please? 
            Hide
            drulli Ulli Hafner added a comment - - edited
            1. We need a new tool class e.g. AnalysisReport (subclass of ReportScanningTool) in the warnings-ng project, see Detekt for an example. This class creates a new parser in the createParser method.
            2. We need a new parser class e.g. ReportParser (extending IssueParser). The parse method of this class should use the same code as AnalysisResult.readIssues(). The code in AnalysisResult already reads a report with several issues, so we basically need to reuse or extract that part.
            Show
            drulli Ulli Hafner added a comment - - edited We need a new tool class e.g. AnalysisReport (subclass of ReportScanningTool ) in the warnings-ng project, see Detekt for an example. This class creates a new parser in the createParser method. We need a new parser class e.g. ReportParser (extending IssueParser ). The parse method of this class should use the same code as AnalysisResult.readIssues() . The code in AnalysisResult already reads a report with several issues, so we basically need to reuse or extract that part.
            Hide
            jmini Jeremie Bresson added a comment -

            I have similar needs, I have made a proposal for a JSON based format in JENKINS-57098.

            Show
            jmini Jeremie Bresson added a comment - I have similar needs, I have made a proposal for a JSON based format in JENKINS-57098 .

              People

              Assignee:
              hobbyte Raphael Furch
              Reporter:
              derrickgw Derrick Gibelyou
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: