`
nanjingjiangbiao_T
  • 浏览: 2594245 次
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

Jenkins(Hudson)+Findbugs/PMD/Checkstyle的配备要点

 
阅读更多
Jenkins(Hudson)+Findbugs/PMD/Checkstyle的配置要点

官方论坛文档写得很烂,让人以为安装了插件后就万事大吉,实际上并不是这样,它只是个静态分析结果的分析插件,而分析结果的生成,却是它完成不了的,你仍然需要在你的ant或maven任务中,写一个任务去执行,生成这个分析结果,通常是一个xml文件,例如:

	
	<!-- =================================================================== -->
	<!-- CheckStyle build -->
	<!-- =================================================================== -->

        <target name="checkstyle" description="Reports the violations of service source against coding style format">
		<taskdef resource="checkstyletask.properties" classpathref="dist.lib" />
		<checkstyle failOnViolation="false" config="${lib.path}/check/CheckStyle_hangame.xml">
			<classpath refid="dist.lib" />
			<fileset dir="${project.src.dir}">
				<include name="**/*.java" />
			</fileset>
			<formatter type="xml" toFile="${commonbuild.dir}/checkstyle_errors.xml" />
		</checkstyle>
	</target>

	<!-- =================================================================== -->
	<!-- Findbugs build -->
	<!-- =================================================================== -->
	<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="dist.lib" />
	<property name="findbugs.home" value="/home/irteam/app/findbugs-1.3.9" />
	<target name="findbugs" depends="build-jar">
		<findbugs home="${findbugs.home}" output="xml" outputFile="${commonbuild.dir}/findbugs_errors.xml">
			<sourcePath path="${project.src.dir}" />
			<class location="${project.dist.dir}/${project.name}.jar" />
		</findbugs>
	</target>

	<!-- =================================================================== -->
	<!-- PMD build -->
	<!-- =================================================================== -->
	<target name="pmd">
		<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="dist.lib" />
		<pmd rulesetfiles="${lib.path}/check/pmd_hangame.xml" encoding="iso-8859-1">
			<formatter type="xml" toFile="${commonbuild.dir}/pmd.xml" />
			<fileset dir="${project.src.dir}">
				<include name="**/*.java" />
			</fileset>
		</pmd>
	</target>

并在findbugs插件中指定你生成的文件名才可以,这里生成的叫findbugs_errors.xml,那么你在插件指定的名字也要叫findbugs_errors.xml,其他两个插件类似,不再赘述.

分享到:
评论
1 楼 comet0515 2016-07-14  
不是maven工程能不能用checkstyle插件?
job是一个HelloWorld的java工程,
配置构建:
                 选择Publish Checkstyle analysis results
                 填写 Checkstyle results:   **/checkstyle_report.xml

其中checkstyle_report.xml需要填写些什么内容吗?构建job后日志提示checkstyle_report.xml为空,跳过此模块。

具体日志如下:
collecting checkstyle analysis files....
finding all files that match the pattern **/checkstyle_report.xml
Parsing 1 files in XXXXXXXXXx(工程路径)
skipping file of module XXXXXxx(工程路径/checkstyle_report.xml) because it's empty
Computing warning deltas based on reference build#1

job主页的checkstyle表显示没有查找出问题
PMD插件同样遇到此问题

相关推荐

Global site tag (gtag.js) - Google Analytics