Skip to content

Instantly share code, notes, and snippets.

@wangwy
Last active May 9, 2016 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wangwy/c8b49df3c1f2e9f1d42a to your computer and use it in GitHub Desktop.
Save wangwy/c8b49df3c1f2e9f1d42a to your computer and use it in GitHub Desktop.
gerrit安装及配置
1.下载
wget http://gerrit-releases.storage.googleapis.com/gerrit-2.9-rc2.war
2.重命名
mv gerrit-2.9-rc2.war gerrit.war
3.
sudo adduser gerrit2 # 添加用户
sudo userdel gerrit2 # 删除用户
sudo su gerrit2
sudo passwd root # 设置root密码
sudo adduser xxx
chmod 777 /etc/sudoers
sudo vim /etc/sudoers
# User privilege specification
root ALL=(ALL) ALL
xxx ALL=(ALL) ALL
chmod 440 /etc/sudoers
4.
java -jar gerrit.war init -d ~/gerrit
java -jar gerrit.war init -d /home/gerrit2/gerrit
_______________________________________________________________________________________________
遇到的问题如下:
用openID认证:
Google:
400. That’s an error.
OpenID auth request contains an unregistered domain: http://dht.goodow.com:8081/code/
无法解决。
提示如下:
https://developers.google.com/accounts/docs/OpenID
_______________________________________________________________________________________________
Outgoing settings
SMTP server: smtp.gmail.com
Port: 465
Security type: SSL (always)
# cat gerrit/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://vpn.pheth.com
[database]
type = h2
database = db/ReviewDB
[index]
type = LUCENE
[auth]
type = HTTP
[sendemail]
smtpServer = smtp.gmail.com
smtpServerPort = 465
smtpEncryption = SSL
smtpUser = danhantao@goodow.com
smtpPass = password
from = Code Review<danhantao@goodow.com>
[container]
user = gerrit2
javaHome = /home/ubuntu/dev/tools/bin/jdk1.7.0_65/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
~~~~~~~~~~~~~~~~~~~~
由于反向代理服务器的配置等问题,造成登陆成功,但是clone的时候,地址如下:
git clone http://vpn.pheth.com/retech/drive-android
造成无法clone下来。
如果换成:git clone http://vpn.pheth.com:8080/retech/drive-android
clone完全没有问题。
canonicalWebUrl = http://vpn.pheth.com 后面加上端口号:8080
可是登陆成功后,http://vpn.pheth.com/#/q/status:open
没有端口号,然后偶然的将
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
删除,然后一切完好。
~~~~~~~~~~~~~~~~~~~~
到目前为止,无法去除8080的端口号。原因不详。
此时:输入http://vpn.pheth.com是不好用的,http://vpn.pheth.com/可以跳转。
sudo ln -snf /home/gerrit2/gerrit/bin/gerrit.sh /etc/init.d/gerrit
sudo ln -snf /etc/init.d/gerrit /etc/rc3.d/S90gerrit
sudo vim /etc/init.d/gerrit
添加:
GERRIT_SITE=/home/gerrit2/gerrit
NO_START=0
重启:
service gerrit restart
sudo apt-get install nginx
sudo vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name vpn.pheth.com;
location / {
auth_basic_user_file /home/gerrit2/gerrit/htpasswd.conf;
auth_basic "Gerrit2 Code Review";
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
sudo /etc/init.d/nginx restart
sudo apt-get install apache2-utils
添加账户:
htpasswd -d htpasswd.conf admin
无法登出:
You are using HTTP Basic authentication. There is no way to tell abrowser to quit sending basic authentication credentials, to logout with basicauthentication is to close the Webbrowser.
退出:
http://nobody:wrongpass@vpn.pheth.com/
gerrit.config
手动添加:
[gitweb]
cgi = /usr/share/gitweb/gitweb.cgi
需要添加权限,其他用户才能查看refs/meta/config的read权限
___________________________________________________________________
问题:
dan@dan-System-Product-Name:~/桌面/danhanta$ ssh -i id_rsa -p 29418 admin@vpn.pheth.com gerrit gsql
fatal: admin does not have "Access Database" capability.
可以在access里面添加Acesss Database
#管理员用命令行穿件新项目。
ssh -p 29418 -i id_rsa admin@vpn.pheth.com gerrit create-project --name retech/drive-android
#查看新项目已经成功创建。
ssh -p 29418 -i id_rsa admin@vpn.pheth.com gerrit ls-projects
All-Users
#查看帮助信息
ssh -p 29418 -i id_rsa admin@vpn.pheth.com gerrit --help
#管理数据库
ssh -p 29418 -i id_rsa admin@vpn.pheth.com gerrit gsql
http://192.168.11.236/tools/hooks/commit-msg
——————————————————————————————————————————————————————————————————————————————————————————————————
ssl:
http://www.freehao123.com/startssl-ssl/
http://www.freehao123.com/nginx-startssl/
gerrit从2.6开始,默认不再添加verified category,也就是changes上就看不到verified label了。
具体的原因见gerrit的Change 44084。这是为了简化out of the box工作流,如果需要与jenkins等CI环境集成,则需要手动添加verified category,只要在All-Projects的project.config文件里添加5行文本就可以了。
添加V标签
$ mkdir temp && cd temp
$ git clone ssh://cr/All-Projects.git
Cloning into 'All-Projects'...
remote: Counting objects: 22, done
remote: Finding sources: 100% (22/22)
remote: Total 22 (delta 1), reused 6 (delta 1)
Receiving objects: 100% (22/22), 5.33 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1/1), done.
Checking connectivity... done.
Note: checking out 'a30b5de24cdd7993bbe3398e57b1cb771cbb1fc2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
$ cd All-Projects
$ vim project.config
在文件project.config中添加如下5行:
[label "Verified"]
function = MaxWithBlock
value = -1 Fails
value = 0 No score
value = +1 Verified
然后提交到远程仓库
$ git commit -a -m "add verified category"
$ git push origin HEAD:refs/meta/config
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 323 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1)
remote: Processing changes: refs: 1, done
To ssh://cr/All-Projects.git
93dc4d8..22b46f7 HEAD -> refs/meta/config
因为在分离头(detached HEAD)状态,所以手工指定将当前HEAD push到远程引用refs/meta/config。
登录gerrit站点,changes上面就有V标签了。
@wangwy
Copy link
Author

wangwy commented Sep 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment