Jenkins + Docker + Python

This is going to be a very brief tutorialish article, nothing too fancy or complicated. You're going to need Docker for this, and the installation instructions are over here for Ubuntu https://docs.docker.com/engine/installation/linux/ubuntulinux/

Once you have Docker setup you just need the official Jenkins docker image from over here https://hub.docker.com/_/jenkins/

docker pull jenkins

docker run -p 8080:8080 -p 50000:50000 jenkins

You can now access Jenkins at localhost:8080

We need to install the git plugin next, in the dashboard page on the left click Manage Jenkins -> Manage Plugins -> Available and install Git plugin and from the list.

After that let's create a new job from the dashboard. Give it a name and pick Freestyle project.

At the Source Code Management section, type in the repo's url and add your credentials.

2016-02-21-121721_1366x768_scrot In the Build Triggers we check Poll SCM and type in H/5 * * * *, this checks the repo for any changes every 5 minutes.

2016-02-21-123417_1366x768_scrotLastly in the Build section we're going to execute a command to run the tests in the repo so from the drop down pick Build then type in command to run the tests

python -m unittest discover  -v

2016-02-21-123747_1366x768_scrotSave all changes and head back to the dashboard.

Now that's done, try pushing a commit to the remote repo. After a few minutes a second build should have started because of a SCM change. 2016-02-21-130727_1366x768_scrot

If you click Console on the left, you can can see that the tests have run successfully.

2016-02-21-131836_1366x768_scrot