安裝APACHE 參照 http://www.cnblogs.com/dudu/archive/2012/12/09/linux-apache-git.html
1.yum list httpd 查詢apache (本次使用的是2.2.15,如果使用的2.4以後的版本配置有所不同)
2.yum install httpd
3.git-team.htpasswd 創建httpd用戶認證的密碼存儲。(注意此文件的用戶組和用戶必須屬於apache)
4.修改httpd的配置文件。 /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName *.*.*.*
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv GIT_PROJECT_ROOT /home/git/source
ScriptAlias / /usr/libexec/git-core/git-http-backend/
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
AuthType Basic
AuthName "Gerrit Code Review"
AuthUserFile /etc/httpd/conf.d/git-team.htpasswd
Require valid-user
</Location>
ProxyPass / http://*.*.*.*:8080/
</VirtualHost>
安裝GERRIT 參照 http://fatalove.iteye.com/blog/1332881
1.下載GERRIT的WAR包。gerrit-2.9.3.war
2.安裝注意點:http認證。
3.配置文件路徑 /home/user/gerrit/site/etc/gerrit.config
[gerrit]
basePath = /home/user/gerrit/repo
canonicalWebUrl = http://*.*.*.*:8080/
[database]
type = mysql
hostname = ****
port = 3306
database = gerrit
username = ***
[index]
type = LUCENE
[auth]
type = HTTP
[sendemail]
smtpServer = smtp.163.com
smtpServerPort = 465
smtpEncryption = ssl
smtpUser = ***
smtpPass = ***
sslVerify = false
from=CodeReview<****@163.com>
[container]
user = user
javaHome = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://***:8080/
[log]
level = debug
[cache]
directory = cache
4.GERRIT可以登錄的用戶爲/etc/httpd/conf.d/git-team.htpasswd這裏邊增加的用戶
第一個登錄的用戶默認爲管理員。(注意使用瀏覽器登錄的時候不要保存密碼,否則很難切換用戶,gerrit的logout無效,只能重啓瀏覽器)
修改個人信息(如果USERNAME爲空,最好還是重新安裝GERRIT),郵件(自動會發送郵件註冊),以及SSH Publickey(開發人員本地生成的RSA公鑰私鑰隊,需要把公鑰複製到這。window下參照下面)。
Window客戶端SSH連接GERRIT的GIT倉庫。
1.git bash生成SSH KEY.(GIT GUI->Help>Show SSH KEy,如果已經存在則複製公鑰),
複製此Key保存到Gerrit.(Setting->SSH Public Keys->add Key)。注意window上最好使用administator用戶。
2.下載代碼 git clone ssh://dev@*.*.*.*:29418/test
3.配置郵件,此郵件必須和gerrit中的郵件一樣。
git config --global user.email "1161558***@qq.com"
git config --global user.name "1161558***@qq.com"
(開發人員 提交代碼到審覈分支)
4.git add hello.txt
5.git commit -a "test"
6.git push origin HEAD:refs/for/master
提示報錯,備註沒有增加changeId(Change-Id: Ie9d2a3533bfc5a9095330bb7b2b13bfa38429d92)
7.git push origin HEAD:refs/for/master(再次提交成功)
(檢閱人員具有review代碼-2 ~ 2 的權限 且具有submit的權限。)
8.檢閱人員登錄系統 All->open 可以看到需要我們審批的代碼。可以審批。
Gerrit我新增了兩個組(dev和rev),測試直接修改All_Project的權限。
當前版本GERRIT已經沒有VERIFY的權限。需要配置 。
參照 http://openwares.net/linux/gerrit_add_verified_label.html