在Jenkins中生成findBugs报告

时间:2017-05-16 00:46:39

标签: jenkins findbugs

我必须从Jenkins运行findBugs并将报告生成到特定文件。我正在寻找执行此操作的详细步骤。

我在Jenkins中添加了插件,并在pom.xml中添加了以下内容

enter code here

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.4.0</version>
            <executions>
                <execution>
                    <id>findbug</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <effort>Max</effort>
                <threshold>Low</threshold>
                <findbugsXmlOutputDirectory>
                    ${project.build.directory}/findbugs
                </findbugsXmlOutputDirectory>
                <failOnError>false</failOnError>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xml-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals>
                        <goal>transform</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <transformationSets>
                    <transformationSet>
                        <dir>${project.build.directory}/findbugs</dir>
                        <outputDir>${project.build.directory}/findbugs</outputDir>
                        <stylesheet>fancy-hist.xsl</stylesheet>
                        <fileMappers>
                            <fileMapper
                                implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                <targetExtension>.html</targetExtension>
                            </fileMapper>
                        </fileMappers>
                    </transformationSet>
                </transformationSets>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.google.code.findbugs</groupId>
                    <artifactId>findbugs</artifactId>
                    <version>2.0.0</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>3.0.3</version>
            <executions>
                <execution>
                    <id>failing-on-high</id>
                    <phase>install</phase>
                    <goals>
                        <goal>findbugs</goal>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <effort>Max</effort>
                        <threshold>Low</threshold>
                        <failOnError>true</failOnError>
                    </configuration>
                </execution>
            </executions>
        </plugin>

如何运行findBugs并生成报告?

1 个答案:

答案 0 :(得分:0)

你需要在findbugs-maven-plugin配置部分中使用它:

          <findbugsXmlOutput>true</findbugsXmlOutput>
          <findbugsXmlWithMessages>true</findbugsXmlWithMessages>
          <xmlOutput>true</xmlOutput>

此外,您需要运行maven目标findbugs:findbugs。您可以在插件说明页面的“如何使用”部分找到详细信息:https://wiki.jenkins-ci.org/display/JENKINS/FindBugs+Plugin