我已经设置Jenkins在所有python源文件上运行 pylint ,并且所有日志文件(显然正确)都生成到一个子目录中,如下所示:
Source\pylint_logs\pylint1.log, pylint2.log, ..., pylint75.log
根据我的Jenkins配置页面上的说明,我包括了--msg-template定义:构建后操作->记录编译器警告和静态分析结果->静态分析工具。模板显示为:
msg-template={path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})
Jenkins / pylint生成的一个日志文件的示例如下:
************* Module FigureView
myapp\Views\FigureView.py:1: [C0103, ] Module name "FigureView" doesn't conform to snake_case naming style (invalid-name)
myapp\Views\FigureView.py:30: [C0103, FigureView.__init__] Attribute name "ax" doesn't conform to snake_case naming style (invalid-name)
------------------------------------------------------------------
Your code has been rated at 8.57/10 (previous run: 8.57/10, +0.00)
对于PyLint 报告文件模式,我有:Source / pylint_logs / pylint * .log
似乎PyLint警告正在解析文件,因为控制台输出看起来像这样:
[PyLint] Searching for all files in 'D:\Jenkins\workspace\PROJECT' that match the pattern 'Source/pylint_logs/pylint*.log'
[PyLint] -> found 75 files
[PyLint] Successfully parsed file D:\Jenkins\workspace\PROJECT\Source\pylint_logs\pylint1.log
[PyLint] -> found 0 issues (skipped 0 duplicates)
[PyLint] Successfully parsed file D:\Jenkins\workspace\PROJECT\Source\pylint_logs\pylint10.log
[PyLint] -> found 0 issues (skipped 0 duplicates)
这对所有75个文件重复一次,即使日志文件中存在很多问题。
奇怪的是,当我第一次在该项目上使用Jenkins制作原型时,我将其设置为仅在单个文件上运行pylint。我遇到了另一个StackOverflow帖子,其中显示了一个msg-template,该模板使我可以使其正常工作(unable to get pylint output to populate the violations graph)。我什至得到了该图以显示PyLint警告趋势。我在帖子中使用了以下定义:
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
请注意,这种格式与我的Jenkins页面推荐的格式略有不同(如前所示)。即使这适用于单个文件,但现在两个模板都似乎不适用于多个文件,否则,除了模板之外,还有其他问题。我的图线平整,我总是收到0个问题的报告。
我在Jenkins PyLint警告工具上找不到有用的文档时遇到了麻烦。是否有人对我可以进一步研究的文档有任何想法或指示?非常感谢!
答案 0 :(得分:0)
确保在 pylint 命令中传递 output-format 参数。示例:
pylint --exit-zero --output-format=parseable module1 module2 > pylint.report