LoginSignup
18
21

More than 5 years have passed since last update.

Jenkinsで静的解析・テスト結果やらのレポートを生成するMavenの設定

Last updated at Posted at 2015-10-22

これは何?

Jenkinsに静的解析、テスト結果をまとめてレポートしてもらう為のMaven設定を記したもの。
※ Jenkins自体への設定は割愛します。

レポートイメージ

Jenkinsの画面から静的解析の結果、テストの結果などが一望できる様な感じ

CI_静的解析レポート.png

バージョン情報

  • maven 3.3.3
  • jenkins 1.634
  • centos 6.5 (Open Logic 6.5)

jenkinsに吐かせたいレポートの内容

  • findbugs
  • checkstyle
  • jUnitのテスト結果
  • カバレッジ測定
  • PMD(Javaソースコード解析の為の静的なルールセット)
  • javadoc生成

必要なJenkinsのプラグイン

※ 標準でインストールされているプラグインを含みます
※ 依存関係でインストールされたプラグインは対象としていません。

  • Checkstyle Plug-in
  • Cobertura Plugin
  • Dependency Analyzer Plugin
  • Duplicate Code Scanner Plug-in
  • FindBugs Plug-in
  • Javadoc Plugin
  • JUnit Plugin
  • JUnit Attachments Plugin(テスト結果にエビデンスを貼り付ける為)
  • Maven Integration plugin
  • PMD Plug-in
  • Static Analysis Collector Plug-in
  • Static Analysis Utilities
  • Task Scanner Plug-in

pom.xmlの中身

※ 試行錯誤の結果、動いた結果を示します。
※ mavenの各プラグインのバージョンは、2015年10月22日現在の情報です。

pom.xml

<projcet>
 ...
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.3-SNAPSHOT</version>
                <configuration>
                    <findbugsXmlOutput>true</findbugsXmlOutput>
                    <xmlOutput>true</xmlOutput>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.17</version>
                <reportSets>
                    <reportSet>
                        <reports><report>checkstyle</report></reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <formats><format>xml</format></formats>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.19</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.5</version>
            </plugin>
        </plugins>
    </reporting>

 ...
</project>

利用するMavenのゴール

mvn
/ compile
/ checkstyle:checkstyle
/ pmd:pmd
/ findbugs:findbugs
/ javadoc:aggregate
/ surefire-report:report
/ cobertura:cobertura -Dcobertura.report.format=xml
18
21
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
21