Jenkins CI and Django Howto

June 13, 2011

Edit 31-01-2013: A new post here, covers more Django-Jenkins topics, with config for push-activated builds from Bitbucket/Github, and more.

I recently set up a Jenkins Continuous Integration server to handle builds for a Django project I have been working on, and during the setup came across some things which may be helpful for other people.

Setting up Jenkins was simple, I used their Ubuntu repository (instructions here), and installed it standalone, though if you prefer, you can also put it in your preferred servlet container.

Integrating Jenkins and Django has been covered in many places - the code you need can be grabbed from PyPI or Github. Having got django-jenkins installed (I personally used pip to download and install the requisite packages), you enable it in your INSTALLED_APPS in settings.py.

INSTALLED_APPS=(
    'django_jenkins',
)

Once that is enabled, you’re ready to set up the project in Jenkins. I looked at a few tutorials online, kmmbvnr’s being the best I came across at time of writing (the author of django-jenkins). I pull the latest code from my git repository, and then build it in Jenkins, using:

python manage.py jenkins

One thing which did cause me some problems was the need to set PROJECT_APPS in settings.py:

PROJECT_APPS = (
    'myapp',
)

This prevents pylint and other suites being run over the whole of django whenever the CI builds your project. This saves on build overhead, and also means you don’t get all the violations etc. for the whole of django, which buries those in your own project.