Gerrit 2.14入门指南

Gerrit是一款免费、开源的代码审查和代码库管理的软件,以Git代码库作为版本控制系统,可以通过命令行、REST和网页界面进行访问。

1.版本

截至2017年5月,最新版本2.14。

2.下载链接

https://gerrit-releases.storage.googleapis.com/gerrit-2.14.war

3.安装

java -jar ~/gerrit-2.14.war init -d ~/myGerritSite

注意,~/myGerritSite为安装路径。

安装过程中的配置参数如下:

  • Location of Git repositories, 默认git
  • Database server type,默认H2
  • Authentication method,默认OPENID
  • Run as,默认当前用户
  • Java runtime, JRE的路径
  • SSH Daemon
    • Listen on address, 默认*
    • Listen on port, Gerrit SSH监听端口默认29418
  • HTTP Daemon
    • Behind reverse proxy,默认y
    • Use SSL, 默认y
    • Listen on address, 默认*
    • Listen on port, Gerrit Web监听端口默认8888

4.Gerrit安装内容

安装完毕,默认设置环境变量如下:

  • $site_path=~/myGerritSite
  • gerrit.basePath=$site_path/git/
  • ...

Gerrit的安装目录,即$site_path,主要包括两类文件,一类是Gerrit元数据文件,另一类是Git库数据文件。

1) Gerrit元数据又分为如下文件:

  • 配置文件$site_path/etc/gerrit.config
  • H2数据文件
  • 服务器的SSH keys文件

查看Gerrit配置文件如下:

[gerrit]
    basePath = git
    canonicalWebUrl = http://gerrit.server
[auth]
    type = HTTP
[container]
    user = gerritadmin
    javaHome = /opt/jdk1.6.0_38/jre
[sshd]  
    listenAddress = *:29418
[httpd]  
    listenUrl = proxy-http://localhost:8888/
[cache]  
    directory = cache

2) Git库数据文件默认位于$site_path/git/。

如果要改变Git库,使用其他Git库,需要执行如下命令:

  • 初始化Git库
git --git-dir=$my_path/new/myproject.git init

  • 创建git-daemon-export-ok文件,以支持匿名访问
touch $base_path/new/myproject.git/git-daemon-export-ok

  • 重启Gerrit服务器,或者flush project_list cache,以注册Git库
ssh -p 29418 localhost gerrit flush-caches --cache project_list

5.Gerrit的Web服务器默认采用嵌入到Jetty,停启Web服务器命令如下:

~/myGerritSite/bin/gerrit.sh start
~/myGerritSite/bin/gerrit.sh stop
~/myGerritSite/bin/gerrit.sh restart


打开浏览器就可以访问http://localhost:8888/即可。


猜你喜欢

转载自blog.csdn.net/taiyangdao/article/details/71078086