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 bu
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:
Ran into this today (although not using Jenkins).
In my case it was because of how Pylint encodes fatal-error-warning-refactor-convention-usage info in its exit code: https://docs.pylint.org/en/1.6.0/run.html#exit-codes
My fix:
#!/usr/bin/env sh
# Wraps Pylint invocation to produce shell-friendly exit codes
# Because Pylint exit codes are weird:
# https://docs.pylint.org/en/1.6.0/run.html#exit-codes
PYTHON_EXECUTABLE=python
if [ ! -z $PYTHON_ENV ]; then
PYTHON_EXECUTABLE="$PYTHON_ENV/bin/python"
fi
${PYTHON_EXECUTABLE} -m pylint $@
PYLINT_EXIT_CODE=$?
exit $(($PYLINT_EXIT_CODE % 4))
(Gist: https://gist.github.com/nkashy1/ae59d06d4bf81fb72047fcd390d08903)