CentOS下Gerrit代码评审服务器的搭建与使用

本文详细介绍了在CentOS7系统中安装配置Gerrit代码评审服务器的步骤,包括安装Gerrit、配置Apache反向代理、注册用户、创建代码库、检出代码、提交评审以及代码评审流程。同时,还涵盖了用户权限管理和SSH公钥的设置。
摘要由CSDN通过智能技术生成

一、准备工作

        安装CentOS7操作系统,准备Gerrit软件安装包:gerrit-2.10.war。

        安装sendmail:

[root@localhost ~]#yum install -y sendmail

        安装apache:

[root@localhost ~]#yum install -y httpd

        创建一个用户用于安装Gerrit:

[root@localhost ~]#adduser gerrit

二、安装Gerrit

        首先切换到gerrit用户:

[root@localhost ~]#su gerrit

[gerrit@localhost root]$cd

[gerrit@localhost ~]$

        安装Gerrit软件:

[gerrit@localhost ~]$java -jar gerrit-2.10.war init -d review2

*** Gerrit Code Review 2.10
*** 

Create '/home/gerrit/review2'  [Y/n]? 

*** Git Repositories
*** 

Location of Git repositories   [git]: 

*** SQL Database
*** 

Database server type           [h2]: 

*** Index
*** 

Type                           [LUCENE/?]: 

*** User Authentication
*** 

Authentication method          [OPENID/?]: HTTP
Get username from custom HTTP header [y/N]? 
SSO logout URL                 : 

*** Review Labels
*** 

Install Verified label         [y/N]? 

*** Email Delivery
*** 

SMTP server hostname           [localhost]: 
SMTP server port               [(default)]: 
SMTP encryption                [NONE/?]: 
SMTP username                  : 

*** Container Process
*** 

Run as                         [gerrit]: 
Java runtime                   [/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64/jre]: 
Copy gerrit-2.10.war to /home/gerrit/review2/bin/gerrit.war [Y/n]? 
Copying gerrit-2.10.war to /home/gerrit/review2/bin/gerrit.war

*** SSH Daemon
*** 

Listen on address              [*]:                       
Listen on port                 [29418]: 

Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v149
  If available, Gerrit can take advantage of features
  in the library, but will also function without it.
Download and install it now [Y/n]? 
Downloading http://www.bouncycastle.org/download/bcpkix-jdk15on-149.jar ... !! FAIL !!


error: www.bouncycastle.org
Please download:

  http://www.bouncycastle.org/download/bcpkix-jdk15on-149.jar

and save as:

  /home/gerrit/review2/lib/bcpkix-jdk15on-149.jar

Press enter to continue 
Continue without this library  [Y/n]? 
Generating SSH host key ... rsa(simple)... done

*** HTTP Daemon
*** 

Behind reverse proxy           [y/N]? y
Proxy uses SSL (https://)      [y/N]? 
Subdirectory on proxy server   [/]: /gerrit
Listen on address              [*]: 
Listen on port                 [8081]: 
Canonical URL                  [http://localhost/gerrit]: http://10.1.5.116/gerrit

*** Plugins
*** 

Install plugin commit-message-length-validator version v2.10 [y/N]?
Install plugin download-commands version v2.10 [y/N]? 
Install plugin replication version v2.10 [y/N]? 
Install plugin reviewnotes version v2.10 [y/N]? 
Install plugin singleusergroup version v2.10 [y/N]? 

Initialized /home/gerrit/review2
Executing /home/gerrit/review2/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server on 10.1.5.116:80 ... OK
Opening http://10.1.5.116/gerrit/#/admin/projects/ ...FAILED
Open Gerrit with a JavaScript capable browser:
  http://10.1.5.116/gerrit/#/admin/projects/
        如果下载bcpkix-jdk15on-149.jar失败,可以手动下载http://www.bouncycastle.org/download/bcpkix-jdk15on-149.jar,再将bcpkix-jdk15on-149.jar放到/home/gerrit/review2/lib/bcpkix-jdk15on-149.jar。
        设置gerrit开机启动:

[gerrit@localhost root]$sudo ln -s /home/gerrit/review2/bin/gerrit.sh /etc/init.d/gerrit.sh

[gerrit@localhost root]$sudo chkconfig --level 345 gerrit.sh on

三、配置Apache反向代理

        在/etc/httpd/init.d中创建gerrit.conf文件,填入下列内容:

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

SetEnv GIT_PROJECT_ROOT /git-repo/
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

ServerName localhost

ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location "/gerrit/login/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile /etc/gerrit.passwd
Require valid-user
</Location>
ProxyPass /gerrit http://localhost:8081/gerrit
        重启httpd服务:

[root@localhost ~]#service httpd restart

        设置httpd开机启动:

[root@localhost ~]#chkconfig --level 345 httpd on

四、注册Gerrit用户

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值