Tags:
Review Board is an open source tool that allows you to conduct code reviews in an easy informal yet structured manner.
It does away with 'over-the-shoulder' reviews and makes email review hell a thing of the past. Each review has its own set of comments and patches in one place, which all developers on the project can see.
I have just finished installing Review Board on Ubuntu Jaunty and thought it might be useful to set out.
This is a step-by-step nothing missing tutorial from a clean Ubuntu install to your first review request.
I chose to use Apache2 with mod_python, as advised by the Review Board team. Apparently there are some issues with running it as fastcgi. To get an apache install capable of serving python pages:
sudo apt-get install apache2 sudo apt-get install libapache2-mod-python sudo apt-get install libapache2-mod-wsgi
First we need to get MySQL and the python bindings for MySQL
sudo apt-get install mysql-serversudo apt-get install python-mysqldb
For faster responses, we are going to install memcache and its python bindings.
sudo apt-get install memcachedsudo apt-get install memcached-dev (无法安装,不安装也可) sudo apt-get install python-memcache
You will need to create a database and a database user for Review Board using the following.
mysql -uroot -pmysql> create database reviewboard; Query OK, 1 row affected (0.00 sec) mysql> create user 'rb'@'%' identified by 'rb_password'; Query OK, 0 rows affected (0.00 sec) mysql> grant all on reviewboard.* to 'rb'@'%' Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
Review Board requires a Subversion client and python bindings, as well as the patch tool.
sudo apt-get install patchsudo apt-get install subversionsudo apt-get install python-svn
Review Board is installed using easy_install. If you don't already have setup tools installed you will need to install it first.
sudo apt-get install python-setuptools sudo easy_install reviewboard
In this tutorial I am assuming that you are creating a dedicated server for Review Board. This means that Review Board will be default site. Installing as a subdomain is readily supported but I have not tested it.
To serve Review Board as the root site, use the following settings:
· Domain = localhost · Root Path = /rb/ · Media URL = media/ (该版本没有这项设置<) · Database Type = mysql · Database Name = reviewboard · Database server = localhost · Database username = 'rb' & password = 'rb_password' or whatever you used earlier in step 2 · Cache Type = memcache · Memcache Server = localhost:11211 · Webserver = apache · Python loader = modpython · Admin account - enter your details here (root / root)
Then wait for all the little green ticks to appear.
Allow all user view the page:
sudo rb-site install cd /var/www/html/reviewboard/conf sudo gedit setting_local.py # 修改最后一行 ALLOWED_HOST = ['*'] sudo service apache2 restartif the ReviewBoard server IP has change(DHCP), please flush the memcache
echo "flush_all" | nc localhost 11211
First you need to allow the apache server to manage the uploads directory with:
sudo chown -R www-data /var/www/html/reviewboard/htdocs/media/uploads sudo chown -R www-data /var/www/html/reviewboard/data
Then you need to copy the site configuration into apache and enable. We are also going to disable the default site and then restart the apache server.
cd /etc/apache2/sites-available cp /var/www/html/reviewboard/conf/apache-wsgi.conf reviewboard.conf cd ../sites-enabled ln -s ../sites-available/reviwboard.conf 000-default.confsudo /etc/init.d/apache2 restart
Note: if you want update you software and systemen, you can (可选):
sudo apt-get update && sudo apt-get dist-upgrade
It's time to fire up your browser and head to http://localhost/rb/ and log in with the administrator credentials.
Head to Admin -> Repositories -> Add Repository and fill in the details and hit save.
post-review is a little tool that makes it easy to send review requests to Review Board. Withoutpost-review you have to manually create the diff file and upload it.
Installation is via easy_install:
sudo easy_install RBTools
On windows you will have to do a few extra steps to get post-review working nicely.
· Install DiffUtils
· Change the name of C:\Python25\Scripts\post-review to C:\Python25\Scripts\post-review.py
· Add C:\Program Files\GnuWin32\bin and C:\Python25\Scripts to the path environment variable
· Changing environment variables in Windows XP
At the top of your subversion checkout create a file called .reviewboardrc and add this line to it:
REVIEWBOARD_URL = "http://localhost/rb/"
If your checkout is not on the same machine as the Review Board server you will need to change localhost to either the servers IP address or domain name.
Go make some changes in your code and save them. On the command line cd into the directory that contains your checkout and .reviewboardrc file and run post-review or post-review.py if you are using windows.
The first time you will be asked to enter your Review Board login username and password.
Go to http://localhost/rb/ and click on 'Outgoing Reviews'. There will one item with a title of [Draft]. Click on [Draft] to complete the Review Request. Fill in all the necessary fields and then click on publish.
(1) Install hooks script. Download the hooks from http://pypi.python.org/pypi/reviewboard-svn-hooks Unzip and then install the scripts to python env. python setup.py install (2)Configuration the hooks /etc/reviewboard-svn-hooks vi config.ini [common] debug=0 [reviewboard] url=http://localhost/rb username=root // For ReviewBoard password=root // For ReviewBoard [rule] min_ship_it_count=1 min_expert_ship_it_count=0 experts= review_path= ignore_path= (3) Change the pre-commit. sudo cp /home/svn/sns/hooks/pre-commit.tpml /home/svn/sns/hooks/pre-commit chmod 777 /home/svn/sns/hooks/pre-commit (new location: /home/tate/svn/testpro/hooks/pre-commit.tpml) and then change the content of pre-commit as below. #!/bin/sh strict_review $1 $2 exit $? (4) Change the script sudo vi /usr/local/lib/python2.7/dist-packages/reviewboard_svn_hooks-0.2.1_r20-py2.7.egg/reviewboardsvnhooks/strict_review.py (new location: /usr/local/lib/python2.7/dist-packages/reviewboard_svn_hooks-0.2.1_r20-py2.7.egg/reviewboardsvnhooks/strict_review.py) def open(self, path, ext_headers, *a, **k): url = urljoin(self._server, path) return self.abs_open(url, ext_headers, *a, **k) è def open(self, path, ext_headers, *a, **k): url = self._server + ‘/’ path return self.abs_open(url, ext_headers, *a, **k)
By now you should have a running install of Review Board with your first Review Request. At this point you will need to get others to sign up and start submitting and reviewing.
There is a comprehensive User Guide available.
Subclipse
Subclipse 1.4.x includes and requires Subversion 1.5.x client features and working copy format.
Subclipse 1.6.x includes and requires Subversion 1.6.x client features and working copy format.
Subclipse 1.8.x includes and requires Subversion 1.7.x client features and working copy format.
Subclipse 1.10.x includes and requires Subversion 1.8.x client features and working copy format.
Links for 1.10.x Release:
Changelog: http://subclipse.tigris.org/subclipse_1.10.x/changes.html
Eclipse update site URL: http://subclipse.tigris.org/update_1.10.x
Zipped downloads: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240
Archived releases: http://subclipse.tigris.org/archive
Links for 1.8.x Release:
Changelog: http://subclipse.tigris.org/subclipse_1.8.x/changes.html
Eclipse update site URL: http://subclipse.tigris.org/update_1.8.x
Zipped downloads: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240
Archived releases: http://subclipse.tigris.org/archive
Links for 1.6.x Release:
Changelog: http://subclipse.tigris.org/subclipse_1.6.x/changes.html
Eclipse update site URL: http://subclipse.tigris.org/update_1.6.x
Zipped downloads: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240
Links for 1.4.x Release:
Changelog: http://subclipse.tigris.org/subclipse_1.4.x/changes.html
Eclipse update site URL: http://subclipse.tigris.org/update_1.4.x
Zipped downloads: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240
参考指南:http://code.taobao.org/p/tao-reviewboard/wiki/index/
请通过Eclipse的Help > Install New Software直接安装http://abs.taobao.org/updatesite/,安装前请先勾选需要安装的模块(请勾选所有模块)。注意:在Help > Install New Software页面,请不要勾选 Contact all update sites during install to find required software。如果勾选了该项,插件安装将是一个漫长的等待过程。
离线安装:离线zip包下载地址 http://code.taobao.org/p/tao-reviewboard/file/2852/tao_reviewboard.zip。下载后,将plugins下两个jar包拷贝至eclipse下的dropins目录(推荐)或者是plugins目录下即可。
Eclipse & TaoReivewBoard settings
(1) Eclipse => Perferences => Team => SVN
In Svn Interface section, set the client to SVNKit
(2) TaoReviewBoard set the server and user
Server: http://www.sns.com/rb
User Id: test
Password: zhenbao@
采用apache+svn,http访问方式。
先确定安装了apache,没有安装则用以下命令:
sudo apt-get install apache2
然后安装subversion及svn-apache连接库:
sudo apt-get install subversion sudo apt-get install libapache2-svn sudo apt-get install apache2-utils
增加svn用户组,用于管理svn,并加入到www-data的apache组:
sudo addgroup subversion sudo usermod -G subversion -a www-data
然后可以创建svn项目仓库了:
# 一般可以将项目仓库建立到/home/svn目录
# 假设项目名为myproject,先建立空目录
$ sudo mkdir /home/svn $ sudo chmod -R o+rw /home/svn $ cd /home/svn $ sudo mkdir myproject $ sudo chown -R root:subversion myproject
#创建为svn项目,使用以下命令
$ sudo svnadmin create /home/svn/myproject
# 然后才赋予组成员对所有新加入文件仓库的文件拥有相应的权限:
# 如果命令顺序搞错,可能会报错,请参照官方wiki
$ sudo chmod -R g+rws myproject
最后是配置apache,用http协议访问svn服务:
# 在安装了libapache2-svn时会自动生成该文件
$ sudo vi /etc/apache2/mods-available/dav_svn.conf
编辑dav_svn.conf配置文件,内有注释,可以去掉前面的#使语句生效,最后内容大概如下即可:
1 <Location /svn> #/svn表示http://hostname/svn/myproject 2 DAV svn 3 SVNParentPath /home/svn 4 AuthType Basic 5 AuthName "ToFishes Project Svn" 6 AuthUserFile /etc/subversion/passwd 7 AuthzSVNAccessFile /etc/subversion/authz 8 Require valid-user 9 </Location>
svn用户文件/etc/subversion/passwd 和 授权访问文件/etc/subversion/authz是不存在的,需要手动创建。
svn用户文件可以通过命令创建:
1 #首次创建需要加-c选项,同时可以增加一个svn用户 2 #执行该命令会提示为新用户user_name设置密码 3 sudo htpasswd -c /etc/subversion/passwd admin 4 #以后添加新用户,需要去掉-c选项,否则以前的用户就被覆灭了 5 sudo htpasswd /etc/subversion/passwd lorry
用户是可以添加了,同时需要管理授权,用于多个svn项目,划分不同的用户组:
用vi /etc/subversion/authz编辑授权文件,无文件则编辑并保存后会自动创建,无需担心。
授权文件内容格式如下:
1 #用户组指令 2 [groups] 3 #格式为 组名 = 用户名1,用户名2 4 subversion = admin, lorry 5 #other groups... 6 #格式为 svn项目的仓库名:对应目录 7 [sns:/] 8 #设置组的权限,r=read, w=write 9 @subversion = rw 10 [sns:/web/css] 11 @group2 = rw
改完最后重启apache :
sudo /etc/init.d/apache2 restart
其中访问地址是什么呢,只要当前服务器已经绑定了一个域名,并且在apache中启用了此域名的虚拟主机。
比如能正常访问 http://www.cssor.com/, 那么svn项目的访问地址就是 http://www.cssor.com/svn/项目名。
Import the codes to svn: svn import ~/Documents/workspace/Pf4jShell/ http://www.sns.com/svn/sns --username admin --password zhenbao@ -m "init." Checkout the code. svn checkout http://www.sns.com/svn/sns sns --username admin --password zhenbao@ svn ci -m "review:1, for test." --username admin --password zhenbao@ LorrymatoMacBook-Pro:sns lorry$ svn ci -m "review:1, for test." Sending src/log4j.properties Transmitting file data .svn: E165001: Commit failed (details follow): svn: E165001: Commit blocked by pre-commit hook (exit code 1) with output: not enough of ship_it. 评审没有通过 already in use 这个ID已经评审完成,不能再使用其进行提交
(0)Config the hosts add bt.sns.com (1)Install env apt-get install apache2 mysql-server libappconfig-perl libdate-calc-perl libtemplate-perl libmime-perl build-essential libdatetime-timezone-perl libdatetime-perl libemail-sender-perl libemail-mime-perl libemail-mime-modifier-perl libdbi-perl libdbd-mysql-perl libcgi-pm-perl libmath-random-isaac-perl libmath-random-isaac-xs-perl apache2-mpm-prefork libapache2-mod-perl2 libapache2-mod-perl2-dev libchart-perl libxml-perl libxml-twig-perl perlmagick libgd-graph-perl libtemplate-plugin-gd-perl libsoap-lite-perl libhtml-scrubber-perl libjson-rpc-perl libdaemon-generic-perl libtheschwartz-perl libtest-taint-perl libauthen-radius-perl libfile-slurp-perl libencode-detect-perl libmodule-build-perl libnet-ldap-perl libauthen-sasl-perl libtemplate-perl-doc libfile-mimeinfo-perl libhtml-formattext-withlinks-perl libgd-dev lynx-cur python-sphinx (2)Download bugzilla Unzip to /var/www/bugzilla (3) Config mysql Edit the conf /etc/mysql/my.cnf Set the following values, which increase the maximum attachment size and make it possible to search for short words and terms: 2 Alter on Line 52: max_allowed_packet=100M 3 Add as new line 31, in the [mysqld] section: ft_min_word_len=2 Save and exit. Then, add a user to MySQL for Bugzilla to use: mysql -u root -p -e "GRANT ALL PRIVILEGES ON bugs.* TO bugs@localhost IDENTIFIED BY '$db_pass'" Replace $db_pass with a strong password you have generated. Write it down. When you run the above command, it will prompt you for the MySQL root password that you configured when you installed Ubuntu. You should make $db_pass different to that password. Restart MySQL: service mysql restart (4) Config apache2 Install cgi by running the cmd as below. a2enmod cgi Edit the apache2 config. /etc/apache2/sites-available/apache-wsgi.conf, and all a virtual host as below. <VirtualHost *:80> ServerName bt.sns.com DocumentRoot /var/www/bugzilla <Directory /var/www/bugzilla> AddHandler cgi-script .cgi Options +ExecCGI DirectoryIndex index.cgi index.html AllowOverride Limit FileInfo Indexes Options </Directory> </VirtualHost> (5) Run checksetup.pl to generate the localconfig cd /var/www/bugzilla ./checksetup.pl (6) Install the missing modules. /usr/bin/perl install-module.pl –all (7) Edit the localconfig nano localconfig You will need to set the following values: 4 Line 29: set $webservergroup to www-data Line 67: set $db_pass to the password for the bugs user you created in MySQL a few steps ago (8) Run the checksetup.pl again ./checksetup.pl (9) Test ./testserver.pl http://bt.sns.com/ (10) Config Bugzilla Once you have worked out how to access your Bugzilla in a graphical web browser, bring up the front page, click Log In in the header, and log in as the admin user you defined in step 10. Click the Parameters link on the page it gives you, and set the following parameters in the Required Settings section: 5 urlbase: http://<servername>/ or http://<ip address>/ Click Save Changes at the bottom of the page. There are several ways to get Bugzilla to send email. The easiest is to use Gmail, so we do that here so you have it working. Visit https://gmail.com and create a new Gmail account for your Bugzilla to use. Then, open the Email section of the Parameters using the link in the left column, and set the following parameter values: 1 mail_delivery_method: SMTP 2 mailfrom: [email protected] 3 smtpserver: smtp.gmail.com:465 4 smtp_username: [email protected] 5 smtp_password: new_gmail_password 6 smtp_ssl: On Click Save Changes at the bottom of the page. And you're all ready to go. :-)