-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Jenkins 1.427
PMD 3.2.0
-
Powered by SuggestiMate
I generate PMD reports through the "mvn clean install site" command. This generates PMD report files correctly within the Maven site. But the PMD jenkins plugin doesn't seem to pick them up at all. In the build status I see:
PMD: 0 warnings from 0 PMD files
Plus I know from the Maven site reports that there are some PMD warnings.
My Maven project 4 modules. The parent pom configures the PMD plugin, but since it has no code, it contains no pmd.xml
If I look at the Jenkins workspace, I can find the pmd.xml correctly in <module>/target/pmd.xml, for each module.
- is related to
-
JENKINS-3654 Intercept the m2 reporter invocation when running the maven site goal
-
- Open
-
-
JENKINS-8650 Report is not picked up when executing Maven goal "verify"
-
- Resolved
-
[JENKINS-10820] PMD plugin does not find report files
Is this a freestyle or m2 project? If freestyle, which pattern did you use? Please check if the selected pmd.xml file actually is an XML results file.
It's an m2 project. I am attaching a sample found in /<module>/target. There are no current warning since we just fixed them, but 2 days ago there were some and jenkins still found 0 pmd files.
Is there anything with the PMD prefix in the console log of your build? E.g.:
[PMD] Aggregating results of Static Analysis Plug-ins Parent POM [PMD] Using set difference to compute new warnings [PMD] Not changing build status, since no threshold has been exceeded
For each of the modules I get:
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
Then a bit lower:
[PMD] Skipping maven reporter: there is already a result available.
Then towards the end of the log:
[PMD] Aggregating results of ds-core
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
[PMD] Aggregating results of ds-cm-default
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
[PMD] Aggregating results of ds-web
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
[PMD] Aggregating results of ds-cm-tester
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
[PMD] Aggregating results of ds-project
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
PMD is invoked indirectly through the "site" goal
I said I was using an m2 project, but its actually on maven 3. Sorry about that.
The Maven version actually does not matter. It's just important if it is a maven or freestyle job.
From the log it seems that the plug-in finds some results. Are there results available for the build pages of the individual modules?
I think I should add more logging about the number of wsrnings found in the aggregation step...
Nope, the build pages for the modules show the same info:
PMD: 0 warnings from 0 PMD files.
Here are the [PMD] messages I see in my log:
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
[INFO] Generating "CPD Report" report — maven-pmd-plugin:2.5
[INFO] Generating "PMD Report" report — maven-pmd-plugin:2.5
[PMD] Skipping maven reporter: there is already a result available.
[PMD] Aggregating results of MyJob
[PMD] Using set difference to compute new warnings
[PMD] Not changing build status, since no threshold has been exceeded
I've worked around the problem by adding the pmd:pmd goal. So I end up with:
mvn clean install pmd:pmd site
This way the jenkins pmd plugin detects the pmd report files correctly.
That's an expensive goal to run twice in one job.
I'll look forward to the official fix.
Would it be possible for someone of you reporters to attach a small sample maven project that has the site goal correctly configured? I tried to add the following to my pom but the site was just empty after running 'mvn site' (I never used the site goal up to now).
<reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> </plugin> </plugins> </reporting>
Using Maven 3 - There must be a maven-site-plugin in <build><plugins>. For example:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-3</version>
<executions>
<execution>
<id>attach-descriptor</id>
<goals>
<goal>attach-descriptor</goal>
</goals>
</execution>
</executions>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<reports>
<report>index</report>
<report>summary</report>
<report>project-team</report>
<report>cim</report>
<report>scm</report>
</reports>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.6</version>
<configuration>
<configLocation>${sca.dir}/checkstyle-5.3/my-checks.xml
</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<rulesets>
<ruleset>${sca.dir}/pmd-4.2.5/my-rules.xml</ruleset>
</rulesets>
<targetJdk>${java-api.version}</targetJdk>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
Ok, I finally managed it to get some content, seems that I did use the wrong site plugin version.
Ok, when I run the 'mvn site' goal I get a PMD result for my plug-ins. Do you have a message like
[PMD] Successfully parsed file /home/hafner/Programs/hudson/jobs/Site (Maven)/workspace/analysis-core/target/pmd.xml of module Static Analysis Utilities with 6 warnings.
in your log?
Code changed in jenkins
User: Ulli Hafner
Path:
src/main/java/hudson/plugins/analysis/core/FilesParser.java
http://jenkins-ci.org/commit/analysis-core-plugin/74c7dc9a699c0b5c1775e727100df84a4cb4d330
Log:
JENKINS-10820 Improved logging if there are no files found (m2).
Integrated in plugins_analysis-core #171
JENKINS-10820 Improved logging if there are no files found (m2).
Ulli Hafner :
Files :
- src/main/java/hudson/plugins/analysis/core/FilesParser.java
I added a logging statement in analysis-core 1.30. Can you please update and retry?
Another option would be to create a small demo-project that would expose that bug...
have the same problem.
during "site" the target/pmd.xml AND target/site/pmd.xml are generated (and filled)
this is what i see in Jenkins (with analysis-core 1.30)
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /export/home/appservd/.m2/repository [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /export/home/appservd/.m2/repository Oct 10, 2011 1:34:21 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/modules/com.mycompany$master-xml-generation/builds/2011-10-10_13-26-44/open-tasks.xml for build 4 Oct 10, 2011 1:34:36 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/open-tasks.xml for build 4 Oct 10, 2011 1:34:38 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/modules/com.mycompany$master-xml-generation/builds/2011-10-10_13-26-44/pmd-warnings.xml for build 4 Oct 10, 2011 1:34:43 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/pmd-warnings.xml for build 4 Oct 10, 2011 1:37:02 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/modules/com.mycompany$master-xml-generation/builds/2011-10-10_13-26-44/checkstyle-warnings.xml for build 4 Oct 10, 2011 1:37:08 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/modules/com.mycompany$master-xml-generation/builds/2011-10-10_13-26-44/findbugs-warnings.xml for build 4 Oct 10, 2011 1:37:09 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/modules/com.mycompany$master-xml-generation/builds/2011-10-10_13-26-44/dry-warnings.xml for build 4 Oct 10, 2011 1:37:11 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/checkstyle-warnings.xml for build 4 Oct 10, 2011 1:37:14 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/findbugs-warnings.xml for build 4 Oct 10, 2011 1:37:15 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/modules/com.mycompany$master-xml-generation/builds/2011-10-10_13-34-13/dry-warnings.xml for build 5 Oct 10, 2011 1:37:15 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/dry-warnings.xml for build 4 Oct 10, 2011 1:37:16 PM hudson.model.Run run INFO: master-xml-generation #5 main build action completed: SUCCESS Oct 10, 2011 1:37:16 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/compiler-warnings.xml for build 4 Oct 10, 2011 1:37:16 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-34-11/checkstyle-warnings.xml for build 5 Oct 10, 2011 1:37:16 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-34-11/pmd-warnings.xml for build 5 Oct 10, 2011 1:37:17 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-34-11/open-tasks.xml for build 5 Oct 10, 2011 1:37:17 PM hudson.plugins.analysis.core.BuildResult loadResult INFO: Loaded data file /export/home/appservd/.hudson/jobs/master-xml-generation/builds/2011-10-10_13-26-40/analysis.xml for build 4
cat'ing the PMD file result in an empty XML
<?xml version='1.0' encoding='UTF-8'?>
checkstyle for example is filled...
Thanks for the project. Now I can reproduce the problem. Seems that the pmd files are generated AFTER the plug-in searches for the files.
Code changed in jenkins
User: Ulli Hafner
Path:
src/main/java/hudson/plugins/analysis/core/HealthAwareReporter.java
http://jenkins-ci.org/commit/analysis-core-plugin/b6217a9a608a1ead95b4584cb98bddb3e6888e00
Log:
[FIXED JENKINS-10820] Don't add an action if there is no result yet.
Integrated in plugins_analysis-core #178
[FIXED JENKINS-10820] Don't add an action if there is no result yet.
Ulli Hafner :
Files :
- src/main/java/hudson/plugins/analysis/core/HealthAwareReporter.java
I'm having a similar issue here.
The plugin doesn't collect pmd.xml unless I explicitly call pmd:pmd in my build.
Jenkins ver. 1.544
Static Code Analysis Plug-ins 1.41
@Jean-Pierre Froud: Please do not comment on resolved issues that might be similar: either create a new issue or discuss your problem in the mailing list before you create the issue (latter is preferred). So we see if this is actually a bug or just a configuration problem.
I also have the Checkstyle plugin setup and that is working fine:
Checkstyle: 0 warnings from 4 Checkstyle files.