在hudson(現在名稱為Jenkins)中整合Python時,參考此文,收錄用作參考。
原文參考:http://www.wallix.org/2011/06/29/how-to-use-jenkins-for-python-development/
At Wallix, we are mainly developing under 2 main environments C/C++ and python. In this article, we are going to cover how we have used Jenkins in our python development process.
We have chosen Jenkins as our continuous integration platform because it supports a wide range of external tools. So far, we have integrated the following features and tools:
- integration with our version control system subversion and git to launch periodic build and checks when modifications arise;
- unit and integration test runners;
- sloccount to have metrics about lines of codes;
- pylint and pyflakes for python code analysis;
- clonedigger for duplicate code detection;
- integration with our ticket management system redmine.
Plugins
To be able to integrate these tools, you need to install these extra plugins:
Then you have to configure these plugins in your project settings page. We are going to give advices for each plugins in the following sections.
SLOCCount
You need sloccount installed in your path of course and then you have to add the following shell script step in your build process:
sloccount --duplicates --wide --details . | fgrep -v .svn > sloccount.sc || :
This will create the sloccount.sc file in your workspace during the build process. You have to active the Publish SLOCCount analysis results
checkbox and configure the file name in theSLOCCount reports
entry field.
Unit tests
We use nosetest to drive our unit tests. You need to add the following shell script test in your build process:
find . -name test*.py|xargs nosetests --with-xunit --verbose || :
and then provide nosetests.xml
as the name of the JUnit file.
Pyflakes
Pyflakes is integrated through the Warnings plugin. You have to add the following shell build step:
find . -name *.py|egrep -v '^./tests/'|xargs pyflakes > pyflakes.log || :
And then add pyflakes.log
as the file pattern for the Scan for compiler warnings
option.
Pylint
Pylint is integrated with the Violation plugin. You have to add the following shell build step:
rm -f pylint.log for f in `find . -name *.py|egrep -v '^./tests/'`; do pylint --output-format=parseable --reports=y $f >> pylint.log done || :
Then add pylint.log
in the Report violations
table for the pylint line.
Clone digger
Clone digger is integrated through the Violation plugin. You have to add the following shell build step:
python ~/clonedigger/clonedigger/clonedigger.py --cpd-output . || :
and then add output.xml
in Report violations
table for the cpd line.
Feedback
We want to ear from you! Do you use the tools the same way we do? Do you use other tools?
Incoming search terms:
- jenkins python
- python jenkins
- jenkins pylint
- how to use jenkins
- pylint jenkins
- pyflakes jenkins
- jenkins pyflakes
- jenkins nosetests
- jenkins python plugin
- jenkins for python