Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven 在Jenkins中配置Findbugs_Maven_Jenkins_Pom.xml_Findbugs - Fatal编程技术网

Maven 在Jenkins中配置Findbugs

Maven 在Jenkins中配置Findbugs,maven,jenkins,pom.xml,findbugs,Maven,Jenkins,Pom.xml,Findbugs,我的目标是让jenkins为我的项目构建失败,以防FindBugs插件报告错误。为此,我在项目的pom.xml中集成了FindBugs配置&配置的执行部分如下 <executions> <execution> <id>analyze-compile</id> <phase>

我的目标是让jenkins为我的项目构建失败,以防FindBugs插件报告错误。为此,我在项目的pom.xml中集成了FindBugs配置&配置的执行部分如下

               <executions>
                    <execution>
                        <id>analyze-compile</id>
                        <phase>compile</phase>
                        <goals><goal>check</goal></goals>
                        <configuration>
                            <threshold>High</threshold>
                        </configuration>
                    </execution>
                </executions>

分析编译
编译
检查
高
我从在线资源中找到了上面的配置&有了这个配置,项目在FindBugs报告错误时不会失败。此外,我还尝试了以下其他配置

<xmlOutput>true</xmlOutput>
<configuration>
    <failOnError>${findbugs.failOnError}</failOnError>
    <threshold>High</threshold>
    </configuration>
<executions>
    <execution>
        <id>noFailOnError</id>
            <phase>verify</phase>
        <goals>
            <goal>check</goal>
        </goals>
            <configuration>                                        
               <failOnError>false</failOnError>
        </configuration>
    </execution>
    <execution>
        <id>failOnError</id>
        <phase>install</phase>
        <goals>
            <goal>check</goal>
        </goals>
            <configuration>
                <failOnError>true</failOnError>
            </configuration>
     </execution>
</executions>
true
${findbugs.failOnError}
高
无故障者
验证
检查
假的
失败者
安装
检查
真的

有人能告诉我在FindBugs中出现bug时,构建失败需要使用什么样的正确执行方式吗?

下面是pom.xml中查找bug的正确配置。它执行以下操作-执行FindBugs检查,在验证阶段生成xml报告,将其转换为html并在检查期间出现错误时失败构建

<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>
                            <!--<stylesheet>default.xsl</stylesheet> -->
                            <!--<stylesheet>plain.xsl</stylesheet> -->
                            <!--<stylesheet>fancy.xsl</stylesheet> -->
                            <!--<stylesheet>summary.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>

org.codehaus.mojo
findbugs maven插件
2.4.0
芬德伯格
验证
检查
马克斯
低
${project.build.directory}/findbugs
假的
org.codehaus.mojo
xml maven插件
1
验证
使改变
${project.build.directory}/findbugs
${project.build.directory}/findbugs
fancy-hist.xsl
.html
com.google.code.findbugs
芬德布格斯
2.0.0
org.codehaus.mojo
findbugs maven插件
3.0.3
失败在高处
安装
芬德布格斯
检查
马克斯
低
真的