Statistics
| Branch: | Tag: | Revision:

root / README.ci @ 5509b599

History | View | Annotate | Download (4 kB)

1 5bde09a4 Georgios Gousios
Continuous integration with Jenkins
2 948121ee Georgios Gousios
===================================
3 948121ee Georgios Gousios
4 948121ee Georgios Gousios
Preparing a GIT mirror
5 948121ee Georgios Gousios
----------------------
6 948121ee Georgios Gousios
7 948121ee Georgios Gousios
Jenkins cannot currently work with Git over encrypted HTTP. To solve
8 948121ee Georgios Gousios
this problem we currently mirror the central Git repository locally
9 948121ee Georgios Gousios
on the jenkins installation machine. To setup such a mirror do the
10 948121ee Georgios Gousios
following:
11 948121ee Georgios Gousios
12 948121ee Georgios Gousios
-edit .netrc
13 948121ee Georgios Gousios
14 948121ee Georgios Gousios
machine code.grnet.gr
15 948121ee Georgios Gousios
login accountname
16 948121ee Georgios Gousios
password accountpasswd
17 948121ee Georgios Gousios
18 948121ee Georgios Gousios
-Create the mirror
19 948121ee Georgios Gousios
20 948121ee Georgios Gousios
git clone --mirror https://code.grnet.gr/git/synnefo synnefo
21 948121ee Georgios Gousios
22 948121ee Georgios Gousios
-Setup cron to pull from the mirror periodically. Ideally, Git mirror updates
23 948121ee Georgios Gousios
should run just before Jenkins jobs check the mirror for changes.
24 948121ee Georgios Gousios
25 948121ee Georgios Gousios
4,14,24,34,44,54 * * * * cd /path/to/mirror && git fetch && git remote prune origin
26 948121ee Georgios Gousios
27 948121ee Georgios Gousios
Jenkins setup
28 948121ee Georgios Gousios
-------------
29 5bde09a4 Georgios Gousios
30 5bde09a4 Georgios Gousios
The following instructions will setup Jenkins to run synnefo tests with
31 75aae73a Georgios Gousios
the SQLite database. To run the tests on MySQL and/or Postgres, step 5
32 5bde09a4 Georgios Gousios
must be replicated. Also, the correct configuration file must be copied
33 948121ee Georgios Gousios
(line 6 of the build script).
34 5bde09a4 Georgios Gousios
35 6940515d Georgios Gousios
1. Install and start Jenkins. On Debian Squeeze:
36 5bde09a4 Georgios Gousios
37 6940515d Georgios Gousios
   wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
38 5bde09a4 Georgios Gousios
   echo "deb http://pkg.jenkins-ci.org/debian binary/" >>/etc/apt/sources.list
39 6940515d Georgios Gousios
   echo "deb http://ppa.launchpad.net/chris-lea/zeromq/ubuntu lucid main" >> /etc/apt/sources.list
40 6940515d Georgios Gousios
   sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C7917B12  
41 5bde09a4 Georgios Gousios
   sudo apt-get update
42 5bde09a4 Georgios Gousios
   sudo apt-get install jenkins
43 5bde09a4 Georgios Gousios
44 75aae73a Georgios Gousios
   Also install the following packages:
45 75aae73a Georgios Gousios
46 75aae73a Georgios Gousios
   apt-get install python-virtualenv libcurl3-gnutls libcurl3-gnutls-dev
47 75aae73a Georgios Gousios
                   uuid-dev libmysqlclient-dev libpq-dev libsqlite-dev
48 6940515d Georgios Gousios
                   python-dev libzmq-dev
49 75aae73a Georgios Gousios
50 5bde09a4 Georgios Gousios
2. After Jenkins starts, go to
51 5bde09a4 Georgios Gousios
52 5bde09a4 Georgios Gousios
   http://$HOST:8080/pluginManager/
53 5bde09a4 Georgios Gousios
54 5bde09a4 Georgios Gousios
   and install the following plug-ins at
55 5bde09a4 Georgios Gousios
56 5bde09a4 Georgios Gousios
   -Jenkins Cobertura Plugin
57 5bde09a4 Georgios Gousios
   -Jenkins Email Extension Plugin
58 5bde09a4 Georgios Gousios
   -Jenkins GIT plugin
59 5bde09a4 Georgios Gousios
   -Jenkins SLOCCount Plug-in
60 5bde09a4 Georgios Gousios
   -Hudson/Jenkins Violations plugin
61 5bde09a4 Georgios Gousios
62 75aae73a Georgios Gousios
3. Configure the Jenkins user's Git details:
63 75aae73a Georgios Gousios
   su jenkins
64 75aae73a Georgios Gousios
   git config --global user.email "buildbot@lists.grnet.gr"
65 75aae73a Georgios Gousios
   git config --global user.name "Buildbot"
66 75aae73a Georgios Gousios
67 75aae73a Georgios Gousios
4. Make sure that all system-level dependencies specified in README.develop
68 5bde09a4 Georgios Gousios
   are correctly installed
69 5bde09a4 Georgios Gousios
70 75aae73a Georgios Gousios
5. Create a new "free-style software" job and set the following values:
71 5bde09a4 Georgios Gousios
72 5bde09a4 Georgios Gousios
-Project name: synnefo
73 5bde09a4 Georgios Gousios
-Source Code Management: Git
74 5bde09a4 Georgios Gousios
-URL of repository: Jenkins Git does not support HTTPS for checking out
75 5bde09a4 Georgios Gousios
                   directly from the repository. The temporary solution
76 5bde09a4 Georgios Gousios
                   is to checkout with a cron script in a directory and
77 5bde09a4 Georgios Gousios
                   set the checkout path in this field
78 5bde09a4 Georgios Gousios
-Branches to build: master and perhaps others
79 5bde09a4 Georgios Gousios
-Git->Advanced->Local subdirectory for repo (optional): synnefo
80 5bde09a4 Georgios Gousios
-Git->Advanced->Prune remote branches before build: check
81 5bde09a4 Georgios Gousios
-Repository browser: redmineweb,
82 5bde09a4 Georgios Gousios
                     URL: https://code.grnet.gr/projects/synnefo/repository/
83 5bde09a4 Georgios Gousios
-Build Triggers->Poll SCM: check
84 6940515d Georgios Gousios
                 Schedule: # every five minutes
85 6940515d Georgios Gousios
			   0,5,10,15,20,25,30,35,40,45,50,55 * * * * 
86 5bde09a4 Georgios Gousios
87 5bde09a4 Georgios Gousios
-Build -> Add build step-> Execute shell
88 5bde09a4 Georgios Gousios
89 5bde09a4 Georgios Gousios
Command:
90 5bde09a4 Georgios Gousios
91 5bde09a4 Georgios Gousios
#!/bin/bash -ex
92 5bde09a4 Georgios Gousios
cd synnefo
93 75aae73a Georgios Gousios
mkdir -p reports
94 5bde09a4 Georgios Gousios
/usr/bin/sloccount --duplicates --wide --details api util ui logic auth > reports/sloccount.sc
95 5bde09a4 Georgios Gousios
cp conf/ci/manage.py .
96 5bde09a4 Georgios Gousios
if [ ! -e requirements.pip ]; then cp conf/ci/pip-1.2.conf requirements.pip; fi
97 6940515d Georgios Gousios
cat settings.py.dist conf/ci/settings.py.sqlite > settings.py
98 5bde09a4 Georgios Gousios
python manage.py update_ve
99 6940515d Georgios Gousios
python manage.py hudson api db logic 
100 5bde09a4 Georgios Gousios
101 5bde09a4 Georgios Gousios
-Post-build Actions->Publish JUnit test result report: check
102 5bde09a4 Georgios Gousios
                     Test report XMLs: synnefo/reports/TEST-*.xml
103 5bde09a4 Georgios Gousios
104 5bde09a4 Georgios Gousios
-Post-build Actions->Publish Cobertura Coverage Report: check
105 5bde09a4 Georgios Gousios
                     Cobertura xml report pattern: synnefo/reports/coverage.xml
106 5bde09a4 Georgios Gousios
107 5bde09a4 Georgios Gousios
-Post-build Actions->Report Violations: check
108 5bde09a4 Georgios Gousios
                     pylint[XML filename pattern]: synnefo/reports/pylint.report
109 5bde09a4 Georgios Gousios
110 5bde09a4 Georgios Gousios
-Post-build Actions->Publish SLOCCount analysis results
111 5bde09a4 Georgios Gousios
                     SLOCCount reports: synnefo/reports/sloccount.sc
112 5bde09a4 Georgios Gousios
                     (also, remember to install sloccount at /usr/bin)
113 5bde09a4 Georgios Gousios
---------------
114 5bde09a4 Georgios Gousios
See also:
115 5bde09a4 Georgios Gousios
116 5bde09a4 Georgios Gousios
http://sites.google.com/site/kmmbvnr/home/django-hudson-tutorial