Statistics
| Branch: | Tag: | Revision:

root / README.ci @ 5509b599

History | View | Annotate | Download (4 kB)

1
Continuous integration with Jenkins
2
===================================
3

    
4
Preparing a GIT mirror
5
----------------------
6

    
7
Jenkins cannot currently work with Git over encrypted HTTP. To solve
8
this problem we currently mirror the central Git repository locally
9
on the jenkins installation machine. To setup such a mirror do the
10
following:
11

    
12
-edit .netrc
13

    
14
machine code.grnet.gr
15
login accountname
16
password accountpasswd
17

    
18
-Create the mirror
19

    
20
git clone --mirror https://code.grnet.gr/git/synnefo synnefo
21

    
22
-Setup cron to pull from the mirror periodically. Ideally, Git mirror updates
23
should run just before Jenkins jobs check the mirror for changes.
24

    
25
4,14,24,34,44,54 * * * * cd /path/to/mirror && git fetch && git remote prune origin
26

    
27
Jenkins setup
28
-------------
29

    
30
The following instructions will setup Jenkins to run synnefo tests with
31
the SQLite database. To run the tests on MySQL and/or Postgres, step 5
32
must be replicated. Also, the correct configuration file must be copied
33
(line 6 of the build script).
34

    
35
1. Install and start Jenkins. On Debian Squeeze:
36

    
37
   wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
38
   echo "deb http://pkg.jenkins-ci.org/debian binary/" >>/etc/apt/sources.list
39
   echo "deb http://ppa.launchpad.net/chris-lea/zeromq/ubuntu lucid main" >> /etc/apt/sources.list
40
   sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C7917B12  
41
   sudo apt-get update
42
   sudo apt-get install jenkins
43

    
44
   Also install the following packages:
45

    
46
   apt-get install python-virtualenv libcurl3-gnutls libcurl3-gnutls-dev
47
                   uuid-dev libmysqlclient-dev libpq-dev libsqlite-dev
48
                   python-dev libzmq-dev
49

    
50
2. After Jenkins starts, go to
51

    
52
   http://$HOST:8080/pluginManager/
53

    
54
   and install the following plug-ins at
55

    
56
   -Jenkins Cobertura Plugin
57
   -Jenkins Email Extension Plugin
58
   -Jenkins GIT plugin
59
   -Jenkins SLOCCount Plug-in
60
   -Hudson/Jenkins Violations plugin
61

    
62
3. Configure the Jenkins user's Git details:
63
   su jenkins
64
   git config --global user.email "buildbot@lists.grnet.gr"
65
   git config --global user.name "Buildbot"
66

    
67
4. Make sure that all system-level dependencies specified in README.develop
68
   are correctly installed
69

    
70
5. Create a new "free-style software" job and set the following values:
71

    
72
-Project name: synnefo
73
-Source Code Management: Git
74
-URL of repository: Jenkins Git does not support HTTPS for checking out
75
                   directly from the repository. The temporary solution
76
                   is to checkout with a cron script in a directory and
77
                   set the checkout path in this field
78
-Branches to build: master and perhaps others
79
-Git->Advanced->Local subdirectory for repo (optional): synnefo
80
-Git->Advanced->Prune remote branches before build: check
81
-Repository browser: redmineweb,
82
                     URL: https://code.grnet.gr/projects/synnefo/repository/
83
-Build Triggers->Poll SCM: check
84
                 Schedule: # every five minutes
85
			   0,5,10,15,20,25,30,35,40,45,50,55 * * * * 
86

    
87
-Build -> Add build step-> Execute shell
88

    
89
Command:
90

    
91
#!/bin/bash -ex
92
cd synnefo
93
mkdir -p reports
94
/usr/bin/sloccount --duplicates --wide --details api util ui logic auth > reports/sloccount.sc
95
cp conf/ci/manage.py .
96
if [ ! -e requirements.pip ]; then cp conf/ci/pip-1.2.conf requirements.pip; fi
97
cat settings.py.dist conf/ci/settings.py.sqlite > settings.py
98
python manage.py update_ve
99
python manage.py hudson api db logic 
100

    
101
-Post-build Actions->Publish JUnit test result report: check
102
                     Test report XMLs: synnefo/reports/TEST-*.xml
103

    
104
-Post-build Actions->Publish Cobertura Coverage Report: check
105
                     Cobertura xml report pattern: synnefo/reports/coverage.xml
106

    
107
-Post-build Actions->Report Violations: check
108
                     pylint[XML filename pattern]: synnefo/reports/pylint.report
109

    
110
-Post-build Actions->Publish SLOCCount analysis results
111
                     SLOCCount reports: synnefo/reports/sloccount.sc
112
                     (also, remember to install sloccount at /usr/bin)
113
---------------
114
See also:
115

    
116
http://sites.google.com/site/kmmbvnr/home/django-hudson-tutorial