51Testing软件测试论坛

标题: CentOS配置Gerrit Gitlab Jenkins--安装Gerrit [打印本页]

作者: 小文0111    时间: 2019-3-14 17:01
标题: CentOS配置Gerrit Gitlab Jenkins--安装Gerrit
1、下载Gerrit

可能需要翻墙,下载地址:https://www.gerritcodereview.com,我下载的版本是2.15.2

2、安装Gerrit

登录CentOS gerrit用户,执行java -jar gerrit-2.15.2.war inti -d /home/gerrit/gerrit_site

*** Gerrit Code Review 2.15.2
***

Create '/home/gerrit/gerrit_site' [Y/n]? y

*** Git Repositories
***

Location of Git repositories   [git]:

*** SQL Database
***

Database server type           [h2]: mysql

Gerrit Code Review is not shipped with MySQL Connector/J 5.1.41
**  This library is required for your configuration. **
Download and install it now [Y/n]? y
Downloading https://repo1.maven.org/maven2/m ... tor-java-5.1.41.jar ... OK
Checksum mysql-connector-java-5.1.41.jar OK
Server hostname                [localhost]: 127.0.0.1
Server port                        [(mysql default)]:
Database name                  [reviewdb]: reviewdb
Database username            [gerrit]: gerrit
gerrit's password               :
             confirm password :

*** Index
***

Type                           [lucene/?]:

*** User Authentication
***

Authentication method          [openid/?]: http
Enable signed push support     [y/N]?

*** Review Labels
***

Install Verified label         [y/N]? y

*** Email Delivery
***

SMTP server hostname           [localhost]: smtp.XX.com
SMTP server port                   [(default)]: 465
SMTP encryption                   [none/?]: ssl
SMTP username                   : gerrit@XX.com

*** Container Process
***

Run as                         [gerrit]:
Java runtime                   [/usr/java/jdk1.8.0_144/jre]:
Copy gerrit-2.14.8.war to /home/gerrit/gerrit_site/bin/gerrit.war [Y/n]? y
Copying gerrit-2.14.8.war to /home/gerrit/gerrit_site/bin/gerrit.war

*** SSH Daemon
***

Listen on address              

  • :
    Listen on port                 [29418]:
    Generating SSH host key ... rsa... dsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done

    *** HTTP Daemon
    ***

    Behind reverse proxy         [y/N]?
    Use SSL (https://)             [y/N]?
    Listen on address              

  • :
    Listen on port                   [8080]: 8008
    Canonical URL                  [http://rx_sctest5:8008/]: http://172.168.1.22:8008 // 这里我使用的是ip,也可以指定host,在发送邮件验证时候需要使用

    *** Cache
    ***


    *** Plugins
    ***

    Installing plugins.
    Install plugin commit-message-length-validator version v2.14.8 [y/N]?
    Install plugin download-commands version v2.14.8 [y/N]?
    Install plugin hooks version v2.14.8 [y/N]?
    Install plugin replication version v2.14.8 [y/N]?
    Install plugin reviewnotes version v2.14.8 [y/N]?
    Install plugin singleusergroup version v2.14.8 [y/N]?
    Initializing plugins.
    No plugins found with init steps.

    Thu May 24 15:32:33 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    Thu May 24 15:32:33 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    Initialized /home/gerrit/gerrit_site
    Executing /home/gerrit/gerrit_site/bin/gerrit.sh start
    Starting Gerrit Code Review: OK
    Waiting for server on 127.0.0.1:8008 ... OK
    Opening http://127.0.0.1:8008/#/admin/projects/ ...OK

    以上安装基本结束,建议将插件全部默认安装。

    3、遇到一些问题

    问题1:Exception in thread "main" com.google.gwtorm.server.OrmException: Cannot apply SQL

    解决办法:
    使用root登录mysql,执行:set global explicit_defaults_for_timestamp=1;

    问题2:java.lang.IllegalStateException: Missing project All-Projects

    解决办法:
    删除所有表,重新安装,如果要重新安装记得删除所有表

    问题3:邮件发送失败

    解决办法:修改/home/gerrit/gerrit_site/etc/gerrit.config,添加from
    [sendemail]
        smtpServer = smtp.XX.com
        smtpServerPort = 465
        smtpEncryption = SSL
        smtpUser = gerrit@XX.com
        from = gerrit@XX.com

    4、配置gitweb

    修改/home/gerrit/gerrit_site/etc/gerrit.config

    [gitweb]
        type = gitweb
        cgi = /var/www/git/gitweb.cgi

    5、最终配置文件

    [gerrit]
        basePath = git
        serverId = 88247b5c-4339-4af7-9c69-35f75b73a1e0
        canonicalWebUrl = http://172.168.1.22:8008
    [database]
        type = mysql
        hostname = localhost
        database = gerrit
        username = gerrit
    [noteDb "changes"]
        disableReviewDb = true
        primaryStorage = note db
        read = true
        sequence = true
        write = true
    [index]
        type = LUCENE
    [auth]
        type = HTTP
    [receive]
        enableSignedPush = false
    [sendemail]
        smtpServer = smtp.XX.com
        smtpServerPort = 465
        smtpEncryption = SSL
        smtpUser = gerrit@XX.com
            from = gerrit@XX.com
    [container]
        user = gerrit
        javaHome = /usr/java/jdk1.8.0_144/jre
    [sshd]
        listenAddress = *:29418
    [httpd]
        listenUrl = proxy-http://*:8008/
    [cache]
        directory = cache
    [gitweb]
        type = gitweb
        cgi = /var/www/git/gitweb.cgi

    检验Gerrit ssh是否可用通过以下办法

    ssh -v -p 29418 admin@127.0.0.1







    欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2