安装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