2

I have setup Jenkins to run pylint on all python source files and all the log files are generated (apparently correctly) into a sub-directory as follows:

Source\pylint_logs\pylint1.log, pylint2.log, ..., pylint75.log

I have included a --msg-template definition based on the instructions on my Jenkins Configure page: Post-build Actions->Record compiler warnings and static analysis results->Static Analysis Tools. The template is shown as:

msg-template={path}:{line}: [{msg_id}, {obj}] {msg} ({symbol})

An example of one of the log files being generated by Jenkins/pylint is as follows:

************* 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)

For the PyLint Report File Pattern, I have: Source/pylint_logs/pylint*.log

It appears that PyLint Warnings is parsing the files because the console output looks like this:

[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)

This repeats for all 75 files, even though there are plenty of issues in the log files.

What is odd, is that when I was first prototyping the use of Jenkins on this project, I set it up to just run pylint on a single file. I ran across another StackOverflow post that showed a msg-template that allowed me to get it working (unable to get pylint output to populate the violations graph). I even got the graph to show up for the PyLint Warnings Trend. I used the following definition per the post:

msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}

Note that this format is slightly different from the one recommended by my Jenkins page (shown earlier). Even though this worked for a single file, neither template now seems to work for multiple files, or else there is something other than the template causing the problem. My graph has flat-lined, and I always get 0 issues reported.

I have had trouble finding useful documentation on the Jenkins PyLint Warnings tool. Does anyone have any ideas or pointers to documentation I can research further? Thanks much!

e-holder
  • 1,504
  • 4
  • 20
  • 33
  • We are running Jenkins ver. 2.89.4, Warnings Plug-In 5.0.1, and Warnings Next Generation Plugin 3.0.3 – e-holder Mar 25 '19 at 15:01

2 Answers2

0

Ensure pass output-format parameter in pylint command. Example:

pylint --exit-zero --output-format=parseable module1 module2 > pylint.report
0

you have to set the Pylint's option --message-template in .pylintrc as

msg-template={path}: {line}: [{msg_id} ({symbol}), {obj}] {msg}
output-format=text