As I am currently part of a software project at university where we are developing some larger part of software in python I decided to locally install the whole continous integration chain at home. For the fun I am doing this on my Odroid U3 board which was also currently idling as my headunit project is on ice…
To get as near as real production chains are I am going to use jenkins for this task although there are many other python alternatives which could handle this much easier – but where is the fun then.
On my odroid is running the latest available image there which is Ubuntu 14.04.2 LTS with 22.214.171.124 kernel. The system is only planned to do this one job therefore the OS is quite naked.
This tutorial is mainly based on steves tutorial which i tried to rewrite.
The first step was to get jenkins. Simply doing an “apt-get install jenkins” works but leaves you with some 2012 version of jenkins (1.4.something) from the official package list of ubuntu – which might be the most stable or whatever – but I want something new! Therefore you need to follow the instructions from jenkins site which is simply adding their own repository:
wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkins
And afterwards jenkins should start up… In my case now version 1.609.
Get other tools
To get the source code everytime something changes we will us the state of the art: git. I think this is self explaining here.
For other parts of the jobs I want to get done by jenkins I’m mostly using the most common alternatives – to make it setup quick and hopefully without any major problems or disruptions. Therefore I am using:
- code management: “git”
- code coverage: “coverage”
- code quality: “pylint”
- unit tests: “unittest”
- testing: “nose”
- mocking: “mock”
All of this can easily pulled by:
sudo apt-get install python-mock python-nose python-coverage pylint git
Install new plugins
- Git Plugin
- Cobertura Plugin
- Global Config user.name Value = Jenkins
- Global Config user.email Value = Jenkins@localhost
To create a job click on “New Item” and choose “Freestyle project” here.
The second part is to check the “Build Triggers” where we check “Poll SCM” and enter 5x* (* * * * *). This lets jenkins check the repository every minute for a new commit.
The third part is to configure the build itself. Therefore click on the dropdown “Add build step” under the “Build” section and select “Execute Shell”. Now paste the following into it:
PYTHONPATH='' nosetests --with-xunit --all-modules --traverse-namespace --with-coverage --cover-package=project1 --cover-inclusive python -m coverage xml --include=project1* pylint -f parseable -d I0011,R0801 project1 | tee pylint.out
To be continued…