|
| 1 | +Integrating Django with Jenkins |
| 2 | + |
| 3 | +Install Jenkins |
| 4 | + |
| 5 | +Installing Python |
| 6 | +Most of the systems with OS like MacOS or Ubuntu already have python installed. You may need to update python to latest version. To do so follow below steps: |
| 7 | +Mac: |
| 8 | +brew udpate |
| 9 | +brew install python3 |
| 10 | +Ubuntu: |
| 11 | +sudo apt-get update |
| 12 | +sudp apt-get install python3 |
| 13 | + |
| 14 | +Create a folder MyProject in your workspace |
| 15 | +Create virtual environment in MyProject as: |
| 16 | +virtualenv myenv |
| 17 | +start virtual environment as: |
| 18 | +source myenv/bin/activate |
| 19 | + |
| 20 | +Install Django |
| 21 | + |
| 22 | +pip install Django |
| 23 | + |
| 24 | +create a project DjangoJenkins |
| 25 | +django-admin startproject DjangoJenkins |
| 26 | +create an app MyApp |
| 27 | +django-admin startapp MyApp |
| 28 | +Install jenkins’ plugins: |
| 29 | +pip install django-jenkins |
| 30 | +pip install pep8 |
| 31 | +pip install pyflakes |
| 32 | +Added jenkins in settings.py: |
| 33 | +In the file DjangoJenkins->DjangoJenkins->settings.py->INSTALLED_APPS add django_jenkins |
| 34 | + |
| 35 | +in settings.py add below lines: |
| 36 | +PROJECT_APPS = ( |
| 37 | +‘MyApp’ |
| 38 | +) |
| 39 | +JENKINS_TASKS = ( |
| 40 | +‘django_jenkins.tasks.run_pep8’, |
| 41 | +‘django_jenkins.tasks.run_pyflakes’ |
| 42 | +) |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +Once you have Django and Jenkins up and running, you can start configuring Jenkins for Django now: |
| 47 | +Start Jenkins. |
| 48 | + |
| 49 | +Create new item: |
| 50 | +Give name to the item: DjangoJenkinExample |
| 51 | +Select Freestyle project |
| 52 | +Click Ok |
| 53 | + |
| 54 | +In Source code Management, select Git and give repo and branch name |
| 55 | + |
| 56 | +In Build Triggers, select Poll SCM |
| 57 | +and write |
| 58 | +H/15 * * * * |
| 59 | +in the text field. |
| 60 | + |
| 61 | +In Build, select exucute shell and white below lines: |
| 62 | +#!/bin/bash |
| 63 | +virtualenv -p python3 myenv |
| 64 | +source myenv/bin/activate |
| 65 | +pip3 install -r requirements.txt |
| 66 | +cd reports |
| 67 | +touch *.xml |
| 68 | +touch *.report |
| 69 | +cd .. |
| 70 | +python3 manage.py jenkins — enable-coverage |
| 71 | + |
| 72 | + |
| 73 | +click Build Now |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
0 commit comments