Hudson下载与安装:
1)下载地址:http://java.net/projects/hudson/downloads/download/war/hudson-2.1.0.war
2)将文件放到tomcat的webapps中,并启动tomcat
3)打开浏览器,确认可以进行访问
Hudson插件安装
1) Checkstyle Plug-in
2) FindBugs Plug-in
3) PMD Plug-in
4) Hudson Cobertura plugin
安装完成后,重新启动hudson
Hudson系统配置
配置一些jdk,ant,maven等信息,此处略。
创建项目
1) 选择maven项目
2) 输入svn的Repository URL。
3) 在Build的配置中,root POM是默认的,不需要进行修改。
Goals and options中输入compile findbugs:findbugs pmd:pmd cobertura:cobertura checkstyle:checkstyle。不要使用site的goals,那样会跳过checkstyle的report。
4) Build Settings中把pmd,findbugs,checkstyle勾选。
5) Post-build Actions中把Publish Cobertura Coverage Report勾选,在Cobertura xml report pattern中输入:**/target/site/cobertura/coverage.xml,其它选项随意。
到此为止,hudson配置项目的工作已经完成。
项目配置
下面是pom.xml文件,只保留了相关插件的配置,请参考:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jdkVersion>1.6</jdkVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<aggregate>true</aggregate>
<linkXref>true</linkXref>
<targetJdk>${jdkVersion}</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<check>
<branchRate>70</branchRate>
<lineRate>70</lineRate>
<haltOnFailure>true</haltOnFailure>
<totalBranchRate>70</totalBranchRate>
<totalLineRate>70</totalLineRate>
<packageLineRate>100</packageLineRate>
<packageBranchRate>100</packageBranchRate>
<regexes>
<regex>
<pattern>xxx.xxx.xxx.xxx.*</pattern>
<branchRate>60</branchRate>
<lineRate>70</lineRate>
</regex>
</regexes>
</check>
<instrumentation>
<ignores>
<ignore>xxx.xxx.xxx.*</ignore>
</ignores>
<excludes>
<exclude>xxx/xxx/xxx/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.7</version>
<configuration>
<configLocation>自己定义的checks xml 文件</configLocation>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<aggregate>true</aggregate>
<linkXref>true</linkXref>
<targetJdk>${jdkVersion}</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</reporting>
<pluginRepositories>
<pluginRepository>
<id>Codehaus repository</id>
<url>http://repository.codehaus.org/</url>
</pluginRepository>
</pluginRepositories>
这篇文章如果对您有帮助,请回复,如果没有帮助,也回复,哈哈哈,就是不管有没有帮助 ,都回复吧。本人不太愿意写东西,回复的少了,就更不愿意写了。