Skip to content

Instantly share code, notes, and snippets.

@danhantao
Last active August 29, 2015 14:04
Show Gist options
  • Save danhantao/be1b8163bf6e192cc7b3 to your computer and use it in GitHub Desktop.
Save danhantao/be1b8163bf6e192cc7b3 to your computer and use it in GitHub Desktop.
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 = [email protected]
smtpPass = password
from = Code Review<[email protected]>
[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:[email protected]/
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 [email protected] gerrit gsql
fatal: admin does not have "Access Database" capability.
可以在access里面添加Acesss Database
#管理员用命令行穿件新项目。
ssh -p 29418 -i id_rsa [email protected] gerrit create-project --name retech/drive-android
#查看新项目已经成功创建。
ssh -p 29418 -i id_rsa [email protected] gerrit ls-projects
All-Users
#查看帮助信息
ssh -p 29418 -i id_rsa [email protected] gerrit --help
#管理数据库
ssh -p 29418 -i id_rsa [email protected] gerrit gsql
http://192.168.11.236/tools/hooks/commit-msg
——————————————————————————————————————————————————————————————————————————————————————————————————
ssl:
http://www.freehao123.com/startssl-ssl/
http://www.freehao123.com/nginx-startssl/
@danhantao
Copy link
Author

保持镜像和远程仓库代码同步:
1.git clone --mirror http://reporistry-url
2.mirror: 定时 git remote update

1.在远程仓库里的hooks目录下,建一个shell脚本:

!/bin/sh

pwd
git push http://reporistry-mirror-url master
用户名密码:~/.netrc 或者 http://name@password:reporistry-mirror-url

2.shell脚本可执行。
那么就可以定时的同步。

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