Use these files to scaffold your Continuous Integration Server within your python projects.
This was inspirated by the PHP jenkins template project (github) by Sebastian Bergmann.
On your jenkins instance, you must install some QA python tools:
-
$ (sudo) apt-get install sloccount
-
$ (sudo) pip install pylint
-
$ (sudo) easy_install clonedigger
-
$ (sudo) pip install nosetests $ (sudo) pip install nosexcover
-
$ (sudo) pip install pyflakes
You also need to install some plugins in your jenkins server:
- Jenkins SLOCCount Plug-in
- Jenkins xUnit plugin
- Jenkins Violations plugin
- Warnings Plug-in
- Cobertura plugin
Install the hudson.plugins.warnings.WarningsPublisher.xml file on the jenkins server, then reload the configuration.
Or, if you prefer to click in the web interface:
-
Go to Manage Jenkins -> Configure System
-
Scroll down to Compiler Warnings -> Parsers
-
Add a new parser with the following details:
-
Name and others descriptive fields:
PyFlakes
-
Regular Expression:
^\s*(.*):(\d+):\s*(.*)$
-
Mapping Script:
import hudson.plugins.warnings.parser.Warning String fileName = matcher.group(1) String lineNumber = matcher.group(2) String message = matcher.group(3) return new Warning(fileName, Integer.parseInt(lineNumber), "Dynamic Parser", "-", message);
-
Example Log Message:
src/fbproxy/fbresponse.py:2: 'json' imported but unused
-
-
Check out the
python-jenkins-template
project from Git:cd $JENKINS_HOME/jobs git clone git://github.com/bobuss/python-jenkins-template.git python-template chown -R jenkins:nogroup python-template/
-
Reload Jenkins' configuration, for instance using the Jenkins CLI:
java -jar jenkins-cli.jar -s http://<jenkins_address>:<jenkins_port> reload-configuration
-
Click on "New Job".
-
Enter a "Job name".
-
Select "Copy existing job" and enter "python-template" into the "Copy from" field.
-
Click "OK".
-
Disable the "Disable Build" option.
-
Fill in your "Source Code Management" information.
-
Configure a "Build Trigger", for instance "Poll SCM".
-
Click "Save".
Get the Makefile
and adapt it (source directory, tasks). Make sure to generate the right files (or change the jenkins config):
- pyflakes.log
- pylint.log
- sloccount.sc
- output.xml
- coverage.xml
- xunit.xml
You can also adapt your .gitignore
file, in order to avoid to commit the generated files.
- http://www.wallix.org/2011/06/29/how-to-use-jenkins-for-python-development/
- http://www.alexconrad.org/2011/10/jenkins-and-python.html
(The MIT License)
Copyright (c) 2012 Bertrand Tornil [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.