Reputation: 69
I have created a jenkins job and below is the pom file. 1. Can you please suggest a way to ignore a certain 'X' number of PMD violations? 2. Is this setup correct to generate PMD reports? Goal in Jenkins is clean install pmd:check site
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<linkXRef>false</linkXRef>
<!--<targetJdk>1.6</targetJdk>-->
<failOnViolation>true</failOnViolation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<linkXRef>false</linkXRef>
<!--<targetJdk>1.6</targetJdk>-->
<failurePriority>5</failurePriority>
<failOnViolation>true</failOnViolation>
<targetDirectory>./pmdOutput</targetDirectory>
<rulesets>
<ruleset>/rulesets/basic.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</reporting>
Upvotes: 1
Views: 2924
Reputation: 704
Since version 3.10.0, PMD has configuration option maxAllowedViolations:
https://maven.apache.org/plugins/maven-pmd-plugin/cpd-check-mojo.html#maxAllowedViolations
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<maxAllowedViolations>180</maxAllowedViolations>
</configuration>
</plugin>
Upvotes: 1
Reputation: 4160
The PMD Maven plugin doesn't allow to setup thresholds on number of violations, it either fails at the first violation of the given priority, or it doesn't.
What I would probably do is not run the pmd:check
target, but have maven generate the reports, and use the Jenkins' PMD plugin to parse the report xml and fail the build if needed.
The PMD plugin for Jenkins does allow more flexible threshold configuration.
Upvotes: 1