Integration of pylint into jenkins

I integrated pylint into Jenkins to get a better code quality overview. Most of the integrations is quite easy and straightforward.

  1. Install the violations plugin for Jenkins.

Jenkins -> Manage Jenkins -> Manage Plugins, or just /pluginManager

  1. Create a pylint config and added it to my repo. Using output-format=parseable
$ pylint --generate-rcfile > pylint.cfg

$ ... customize pylint.cfg
$ git add pylint.cfg
$ git commit -a -m "added pylint"
$ git push
  1. Added the pylint run to my Jenkins build job.

Jenkins -> MyJob -> Configure

Add build step -> Execute shell

if [ ! -d venv ] ; then

   virtualenv --python=python2.7 venv
fi
source venv/bin/activate
export PYTHONPATH="$PWD:$PYTHONPATH"

pip install pylint

cd repo
### Need this because some strange control sequences when using default TERM=xterm
export TERM="linux"

## || exit 0 because pylint only exits with 0 if everything is correct
pylint --rcfile=pylint.cfg $(find . -maxdepth 1 -name "*.py" -print) MYMODULE/ > pylint.log || exit 0
  1. Add the Violation reporting

Jenkins -> MyJob -> Configure

Add post-build Action -> Report Violations

Filled the field pylint with the pattern **/pylint.log

/posts/pylint.thumbnail.png

So the next build also performed the pylint run, and generated the report with graphs.

/posts/pylintgraph1.thumbnail.png

... with the list of source files.

/posts/pylintgraph2.thumbnail.png

Unfortunately, on click onto the filename, I got an empty page, where I expected the source view, including detected warnings and errors.

I quick search on the jenkins server showed the xml results of the pylint run. The xml was valid, and seemed to be correct. So the reneration of the report should not be the problem.

A web search just gave me some defects, similar to my problem, but the tickets all are still open. So I digged around in the Violations cofiguration in MyJob. Just by "educated guess", I filled the field "Source Path Pattern" with **/

/posts/pylintsourcefiles.thumbnail.png

et voila, the the results for each file were available after the next build.