Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins with pylint gives build failure

I added a build step to execute a Python script.
In this script pylint is called with the lint.Run(..args) to check the code.
The script works but in the end, the build fails with the only error message:

Build step 'Execute Python script' marked build as failure

Someone has an idea why this happens?

like image 402
Gobliins Avatar asked Sep 08 '11 11:09

Gobliins


3 Answers

You can also simply put a

pylint || exit 0

in the shell cmdline. The Pylint plugin will fail the build anyway by checking the result of pyllint.

like image 191
fabrizioM Avatar answered Nov 09 '22 08:11

fabrizioM


In Pylint 1.9.3, there is a --exit-zero flag.

https://github.com/PyCQA/pylint/blob/1.9/ChangeLog#L47

like image 40
sheryl pinto Avatar answered Nov 09 '22 08:11

sheryl pinto


Pylint has the unpleasant behavior to return a non-zero exit code even only if a small warning issue was found. Only when everything was fine, 0 is returned (see man page).

As usually a non-zero code denotes an error, Jenkins fails the build.

I see two ways to overcome this:

  • Use a small script around pylint that always returns 0. Then jenkins will not fail because of pylint. I use a small python script calling pylint with os.system() and sys.exit(0) after than. You can see it as overriding the error code of pylint.
  • Patch pylint. For example, on my Linux system the sys.exit() call is in the file /usr/lib/pymodules/python2.6/pylint/lint.py
like image 14
dmeister Avatar answered Nov 09 '22 08:11

dmeister