jenkinsci / violation-comments-to-gitlab-plugin

Comments GitLab merge requests with static code analyzer findings.
https://plugins.jenkins.io/violation-comments-to-gitlab
MIT License
20 stars 4 forks source link

Problem reading report #13

Closed mnunezdm closed 6 years ago

mnunezdm commented 6 years ago

Hi im currently facing this problem, maybe i havent undestand the plugin correnctly

Im currently generating a report using PMD with this call, which generates a xml file with 5 violations...

$PMD_HOME/bin/run.sh pmd -d srcToDeploy -R "$PMD_HOME/rules.xml" -f xml -r csv-delta.xml -failOnViolation false

After this im calling your plugin with the next command

ViolationsToGitLab([apiToken: 'MYAPITOKEN', apiTokenCredentialsId: 'jenkins-violations', apiTokenPrivate: true, authMethodHeader: false, gitLabUrl: 'https://gitlab.com',
    ignoreCertificateErrors: true, mergeRequestId: env.gitlabMergeRequestIid, projectId: env.gitlabMergeRequestTargetProjectId,
    violationConfigs: [[parser: 'PMD', pattern: 'csv-delta.xml', reporter: '']]])

This generates this result

[Code Quality Tests] --- [Code Quality Tests] --- Violation Comments to GitLab --- [Code Quality Tests] --- [Code Quality Tests] gitLabUrl: https://gitlab.com [Code Quality Tests] projectId: 5606826 [Code Quality Tests] mergeRequestId: 34 [Code Quality Tests] apiToken: true [Code Quality Tests] apiTokenCredentialsId: true [Code Quality Tests] ignoreCertificateErrors: true [Code Quality Tests] apiTokenPrivate: true [Code Quality Tests] authMethodHeader: false [Code Quality Tests] createCommentWithAllSingleFileComments: false [Code Quality Tests] commentOnlyChangedContent: false [Code Quality Tests] minSeverity: INFO [Code Quality Tests] keepOldComments: true [Code Quality Tests] shouldSetWip: false [Code Quality Tests] PMD with pattern csv-delta.xml [Code Quality Tests] Running Violation Comments To GitLab [Code Quality Tests] Merge request: 34 [Code Quality Tests] Workspace: /var/lib/jenkins/workspace/liquidstudio-jenkins-demo [Code Quality Tests] Found 0 violations from ViolationConfig [pattern=csv-delta.xml, parser=PMD, reporter=]. [Code Quality Tests] Will comment PR https://gitlab.com 5606826 34

The number of violations is 0 when in the xml i generate with the pmd i have 5...

Im doing anything wrong??

Thank you!

mnunezdm commented 6 years ago

I have tried using different patterns, maybe is the problem....

I have tried with

  pattern: 'csv-delta\\.xml'

Renaming the file to csvdelta.xml pattern: 'csvdelta\.xml' pattern: 'csvdelta\.xml$' Saving the report in a folder named findbugs (just like the example said) pattern: './findbugs/.\.xml$'

tomasbjerre commented 6 years ago

.*/csv-delta\.xml$ should work. Which version is this? What is the content of csv-delta.xml?

mnunezdm commented 6 years ago

.*/csv-delta\.xml$ This

This is the xml im parsing, its basically the one that the pmd generates by default

$ cat csvdelta.xml

<?xml version="1.0" encoding="UTF-8"?>
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd"
    version="6.1.0" timestamp="2018-03-07T08:21:41.695">
    <file name="src/CustomTableClass.java">
        <violation beginline="1" endline="1" begincolumn="14" endcolumn="29" rule="RULE1" ruleset="Security" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_security.html#RULE1" priority="3">
            Description 1
        </violation>
        <violation beginline="1" endline="242" begincolumn="14" endcolumn="11" rule="RULE2" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE2" priority="3">
            Description 2
        </violation>
        <violation beginline="1" endline="242" begincolumn="14" endcolumn="11" rule="RULE3" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE3" priority="3">
            Description 3
        </violation>
        <violation beginline="1" endline="242" begincolumn="14" endcolumn="11" rule="RULE4" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE4" priority="3">
            Description 4
        </violation>
        <violation beginline="39" endline="39" begincolumn="17" endcolumn="18" rule="RULE5" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE5" priority="3">
            Description 5
        </violation>
    </file>
</pmd>
tomasbjerre commented 6 years ago

Which version of the plugin?

tomasbjerre commented 6 years ago

I added a testcase and verified there is nothing wrong with the contents of the report. https://github.com/tomasbjerre/violations-lib/commit/c36c7bd5a99a442af8e60f32191852757b60f3e6

mnunezdm commented 6 years ago

Hi!

Im currently using the last version 1.28

mnunezdm commented 6 years ago

I finally managed to do this with this pattern

pattern: '.*/csvdelta\.xml$'

thank you!

tomasbjerre commented 6 years ago

So the filename is actually csvdelta and not csv-delta?