Jenkins + Docker + Python
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.
In the Build Triggers we check Poll SCM and type in H/5 * * * *, this checks the repo for any changes every 5 minutes.
Lastly 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
Save 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.
If you click Console on the left, you can can see that the tests have run successfully.