Checkstyle和Findbugs仅在Jenkins(和/或Hudson)上查找更改的文件 [英] Checkstyle and Findbugs for changed files only on Jenkins (and/or Hudson)

查看:103
本文介绍了Checkstyle和Findbugs仅在Jenkins(和/或Hudson)上查找更改的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用许多旧代码,我们考虑为新代码引入一些指标.是否可以让Findbugs和Checkstyle仅在更改的文件而不是完整的项目上运行?

We work with a lot of legacy code and we think about introducing some metrics for new code. Is it possible to let Findbugs and Checkstyle run on changed files only instead of a complete project?

最好确保仅检入质量最低的文件,但尚未(尚未)触碰和评估代码库本身,以免使成千上万的问题引起人们的困惑.

It would be nice to assure that only file with a minimum of quality is checked in, but the code base itself is not (yet) touched and evaluated not to confuse people by thousands of issues.

推荐答案

从理论上讲,这是有可能的.在给定开始日期之后,您将使用Shell脚本来解析SVN(或任何SCM)更改日志,从这些更改集中识别.java文件,并从中建立两种模式:

In theory, it would be possible. You would use a shell script to parse the SVN (or whatever SCM) change logs after a given start date, identify the .java files from these change sets and build two patterns from these:

  • The Findbugs Maven Plugin expects a comma-separated list of class (or package) names for the parameter onlyAnalyze, so you'll have to translate file names to fully qualified class names (this will get tricky when you're dealing with inner classes)
  • The Maven Checkstyle Plugin is even worse, it expects a configuration file for its packageNamesLocation parameter. Unfortunately, only packages are allowed, not individual files. So you'll have to translate file names to packages.

在以上示例中,我假设您正在使用maven.我很确定蚂蚁可以完成类似的事情,但我不知道.

In the above examples I assume that you are using maven. I am pretty sure that similar things can be done with ant, but I wouldn't know.

我本人可能会使用Groovy脚本而不是Shell脚本来实现上述结果.

I myself would probably use a Groovy script instead of a shell script to achieve the above results.

这篇关于Checkstyle和Findbugs仅在Jenkins(和/或Hudson)上查找更改的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆