Hudson and PythonSeptember 23rd, 2010 • 3 Comments
Regarding Continuous Integration (CI) systems I probably still like Hudson! Great tool and runs perfectly well. Just get the latest jar file and run it with java – jar hudson.jar. Now to get started you will need to install some plugins:
- the Python plugin
- the mercurial (or whatever SCM you use) plugin
- Violations Plugin (which will parse pylint output later on)
- Cobertura Plugin (which will parse the coverage output and display it nicely)
You can install those plugins in he management interface of hudson. When configuring the job in hudson you simple add a new “Build a free-style software project” job. Add SCM information – and than add some build steps. I had to use two:
python setup.py clean --all python setup.py build coverage erase nosetests --with-coverage --cover-package=<your packages> --with-xunit coverage xml
And a second one:
#!/bin/bash pylint -f parseable <your packages> > pylint.txt echo "pylint complete"
Both are external scripts. Now in the post-build section activate the JUnit test reporting and tell it to use the **/nosetests.xml file. Also activate the Cobertura Coverage report and tell it to use **/coverage.xml. Finally activate the Report Violations – and add pylint.txt in the right row.
Configure the rest of the stuff just as you like and hit the Build button. Thanks to XML the reporting tools written for java can parser the output generated for your Python project. Now you have nice reports from a Python project in Hudson!
A more detailed and great article about this topic can be found here.
Why do you need to use two build steps? In my Hudson setup I just put all the commands in to one script that runs as a single build step.
By convention we just call the script “hudson.sh” and keep it in source control along with the project. Handy to track as the build changes, and less work when setting up builds for branches etc.
pylint would not complete otherwise 🙂 Do you have pylint in you setup? I probably will refactor that stuff as well and create a hudson script.
[…] & Builds – Probably because I have some Sun Microsystems background I like hudson – It runs as a service on my machine in the background and is bound to my local branch of my […]