在jenkins中使用findbugs并自定义错误类型 jenkinsfindbugsfindbugs自定义错误类型maven
1.项目使用mvn管理。
mvn archetype:create -DgroupId=com.cx -DartifactId=child1 -DarchetypeArtifactId=maven-archetype-quickstart
2.在maven的pom文件中增加构建插件maven-site-plugin和报表插件findbugs-maven-plugin
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cx</groupId>
<artifactId>findbugstest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>findbugstest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<port>7002</port>
<tempWebappDirectory>target/site/tempdir</tempWebappDirectory>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<docencoding>${file.encoding}</docencoding>
<charset>${file.encoding}</charset>
<encoding>${file.encoding}</encoding>
</configuration>
</plugin>
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.3</version>
<!--
<FindBugsFilter>
- <Match>
<Bug pattern="URF_UNREAD_FIELD,UUF_UNUSED_FIELD,DLS_DEAD_LOCAL_STORE,UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD,RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE" />
</Match>
</FindBugsFilter>
-->
<configuration>
<!--
<omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors>
-->
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<xmlOutput>true</xmlOutput>
<xmlOutputDirectory>target/site</xmlOutputDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
3.排除的错误类型findbugs-exclude.xml文件如下。与pom.xml文件同级目录。
<FindBugsFilter>
<Match>
<!--
<Bug pattern="URF_UNREAD_FIELD,UUF_UNUSED_FIELD,DLS_DEAD_LOCAL_STORE,UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD,RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"/>
-->
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"></Bug>
<!--
<Bug pattern="DLS_DEAD_LOCAL_STORE"/>
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
-->
</Match>
</FindBugsFilter>
4.提交项目到SVN。
5.在jenkins中配置构建方法 mvn site:site。构建成功后就可以直接自jenkins左边命令行链接中看到那个可能findbugs红色虫子了。
上一篇: EL表达式截取字符串
下一篇: 含有中英文的字符串截取