Simple python job on Jenkins

In this tutorial i show, how you as a tester can create a very basic python code analysis and documentation job in your build server.

Preparation

Install needed python modules

$ pip install pylint
$ pip install pep8
$ pip install epydoc

Install needed Jenkins plugins

  • HTML Publisher Plugin
  • Violations

Create a Free Style job

Create a new job with your requirements (e.g. Project name, Source-Code Management, etc.). Now insert commands “Build > Execute Shell”.

pep8 ${WORKSPACE}/<module|file> > pep8_report.txt

echo "pep8 complete"

pylint -f parseable ${WORKSPACE}/<module|file> | tee pylint_report.txt

echo "pylint complete"

[ -d ${WORKSPACE}/API ] && rm -fr ${WORKSPACE}/API

epydoc ${WORKSPACE}/<module|file> --html --name 'My Project API' -o ${WORKSPACE}/API/

echo "epydoc complete"

Add the Post-Build-Action – Report Violations and Publish HTML reports. On violations insert the pep8 (pep8_report.txt) and pylint (pylint_report.txt) values. On Publish HTML reports add the folder API.

After running the build, the screen should look like this:

Jenkins Python Report