配置Gerrit的邮箱信息,然后设定用户可以注册邮件,最后重启服务。这里需要注意一点的是:有可能你的gerrit启动比较的慢,不要心急,通过ps 查看进程是否挂掉了,如果挂掉了,就说明配置有问题了,如果没有就安静等待,然后查看端口号的服务是否有了,如果有了,就说明启动ok了。

1、配置邮箱

我们必须提供一个邮箱给gerrit,不然gerrit就不能发送邮件给用户了,让用户去绑定gerrit了。

vim etc/etc/gerrit.config

#下面是腾讯企业邮箱配置
[sendemail]
        enable = true
        smtpServer = smtp.exmail.qq.com
        smtpServerPort = 465
        smtpEncryption = SSL
        sslVerify = true
        smtpUser = 717350389@yellowcong.com
        smtpPass = testpass
        from = 717350389@yellowcong.com

2、配置用户可以设置邮箱

[oauth]
        allowEditFullName = true
        allowRegisterNewEmail = true

3、完整的配置

[gerrit]
    basePath = git
    serverId = 4de95b40-e3be-4a9b-bf36-76a3a2421d4a
    canonicalWebUrl = http://gerrit.yellowcong.net:8081
[database]
    type = mysql
    hostname = localhost
    database = reviewdb
    username = root
[index]
    type = LUCENE
[auth]
    type = OAUTH
    gitBasicAuthPolicy = HTTP
[oauth]
    allowEditFullName = true
    allowRegisterNewEmail = true
[receive]
    enableSignedPush = true
[sendemail]
        enable = true
        smtpServer = smtp.exmail.qq.com
        smtpServerPort = 465
        smtpEncryption = SSL
        sslVerify = true
        smtpUser = gerrit@yellowcong.cn
        smtpPass = yellowcong_123
        from = gerrit@yellowcong.cn
[container]
    user = root
    javaHome = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/jre
[sshd]
    listenAddress = *:29418
[httpd]
    listenUrl = http://*:8081/
[cache]
    directory = cache
[plugin "gerrit-oauth-provider-cas-oauth"]
    root-url = http://yellowcong.com:9000
    client-id = 1100660
    fix-legacy-user-id = false

4、重启服务

重启失败了,是正常的,实际上没有失败,还在运行

bin/gerrit.sh restart

#查看进程
ps -ef|grep gerrit 

#查看端口,服务是否启动正常
netstat -nptl

可以看到的是,服务已经启动失败,但是实际上,服务还在运行中。

Centos之Gerrit邮箱配置-yellowcong_gerrit

我电脑启动比较的慢,所以每次都得等个5分钟左右才启动起来,菊花藤,还能说啥呢。

Centos之Gerrit邮箱配置-yellowcong_gerrit_02

看看我的启动时间,我还能说啥呢,菊花疼啊。

Centos之Gerrit邮箱配置-yellowcong_重启_03

常见问题

1、realm does not allow adding emails

这个问题是由于用户不能注册邮箱,这个问题是由于默认配置的不支持邮箱更改的。

Centos之Gerrit邮箱配置-yellowcong_html_04

添加下面配置,设定可以修改用户名和设定新的邮箱。

Centos之Gerrit邮箱配置-yellowcong_centos_05

[oauth]
        allowEditFullName = true
        allowRegisterNewEmail = true