2012年6月3日 星期日

Gerrit 安裝

[Server]
# apt-get install mysql-server mysql-client postfix sun-java6-jre

mysql -u root -p
mysql> CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'gerrit';
mysql> CREATE DATABASE reviewdb;
mysql> ALTER DATABASE reviewdb charset=latin1;
mysql> GRANT ALL ON reviewdb.* TO 'gerrit'@'localhost';
mysql> FLUSH PRIVILEGES;

# useradd -m gerrit
# su - gerrit

$ wget http://gerrit.googlecode.com/files/gerrit-2.4.war
$ chmod 744 gerrit-2.2.1.war
$ java -jar gerrit-2.2.1.war init -d review_sites

*** Gerrit Code Review 2.4
***


*** Git Repositories
***

Location of Git repositories   [git]:

*** SQL Database
***

Database server type           [MYSQL/?]:
Server hostname                [localhost]:
Server port                    [(MYSQL default)]:
Database name                  [reviewdb]:
Database username              [root]: gerrit
Change gerrit's password       [y/N]? y
gerrit's password              :
              confirm password :

*** User Authentication
***

Authentication method          [OPENID/?]:

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [NONE/?]:
SMTP username                  :

*** Container Process
***

Run as                         [gerrit]:
Java runtime                   [/usr/lib/jvm/java-6-sun-1.6.0.24/jre]:
Upgrade /home/gerrit/review_sites/bin/gerrit.war [Y/n]?
Copying gerrit.war to /home/gerrit/review_sites/bin/gerrit.war


*** SSH Daemon
***

Listen on address              [*]: Listen on port                 [29418]:

*** HTTP Daemon
***

Behind reverse proxy           [y/N]?
Use SSL (https://)             [y/N]?
Listen on address              [*]:
Listen on port                 [8080]:
Canonical URL                  [http://localhost:8080/]:

Initialized /home/gerrit/review_sites

$ ~/review_sites/bin/gerrit.sh restart


 [Client]
進入 Gerrit 網頁 http://localhost:8080/
Registered the first user with openid. // 註冊的第一位使用者將自動成為主管理員
Add SSH Public Keys
 
$ ssh -p 29418 yan@your_domain
  ****    Welcome to Gerrit Code Review    ****

  Hi yan, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://yan@localhost:29418/REPOSITORY_NAME.git

Connection to localhost closed.


$ ssh -p 29418 yan@localhost gerrit create-project -n sandbox
$ git clone ssh://yan@localhost:29418/sandbox.git 
Cloning into 'sandbox'...
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ cd sandbox
$ touch README
$ git add *
$ git commit
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 202 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done   
To ssh://yan@localhost:29418/sandbox.git
 ! [remote rejected] master -> master (can not create new references)
error: failed to push some refs to 'ssh://yan@localhost:29418/sandbox.git'

原因:Gerrit不希望我们直接覆写Git代码库中的任何分支

$ git config remote.origin.push refs/heads/*:refs/for/*
or
$ git config remote.origin.push HEAD:refs/for/master

$ git push origin


* 專案管理可用 git-review 工具代替


進入網頁 http://localhost:8080/ 選單 My -> Changes 即可看到待審核的提交






Reference :
Cherry-picking Pearls in San Francisco: My take on installing gerrit (git code review tool) on ubuntu
Gerrit unter Ubuntu installieren | seeseekey.net
InfoQ: Git、Gerrit与Jenkins/Hudson CI服务器
John Hsing's Blog: 初试 Gerrit


Further :
隨手誌: git push到gerrit review server的方法與設定

沒有留言:

張貼留言