Duplicate checkstyle warnings in a jenkins maven multimodule job

你说的曾经没有我的故事 提交于 2019-12-10 19:17:19

问题


I have a jenkins maven job with an aggregator pom and a bunch of submodules. When jenkins displays the checkstyle warnings it does it like so:

  • submodule 1: 10 warnings
  • submodule 2: 10 warnings
  • Aggregator module: 20 warnings

  • Total: 40 warnins

In other words, the aggregator (rightfully?) aggregates the warnings found in the submodules, which wouldn't be such a big problem if it weren't because the total then becomes double what it should be.

Does any one know what the problem is? Thanks!


回答1:


This depends on whether you are using the Freestyle project type or the Evil Maven Project type.

If you are using freestyle, you just need to set your pattern for checkstyle.xml results to exclude the aggregator or exclude the sub-projects.

If you are using the evil sibling, you may need to tweak the 'per-module' config to disable the reports for the child modules.

The issue here is that the aggregator module is copying the warnings from the child projects in order to produce an aggregated report.

You could also disable the aggregation when the job runs on Jenkins.

It's basically a fight between the auto-sniffing "magic" from the evil project type and the way the maven-checkstyle-plugin implements the aggregate reporting.




回答2:


You can adapt some of the tricks from here

Add the following to the aggregator pom:

<project>
  ...
  <profiles>
    ...
    <profile>
      <id>on-jenkins</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <inherited>false</inherited>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    ...
  </profiles>
  ...
</project>

And add -P+on-jenkins to your Maven goals on the Jenkins job.



来源:https://stackoverflow.com/questions/13430904/duplicate-checkstyle-warnings-in-a-jenkins-maven-multimodule-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!