zoukankan      html  css  js  c++  java
  • Gerrit

    1 - GitWeb简介

    GitWeb是一个支持在Web页面上查看代码以及提交信息的工具。
    安装GitWeb工具并且集成到Gerrit中,就可以直接在Gerrit的项目列表中查看项目的代码信息。

    2 - 安装GitWeb

    启动gerrit服务

    [gerrit@mt101 ~]$ sudo gerrit_testsite/bin/gerrit.sh start
    Starting Gerrit Code Review: OK
    [gerrit@mt101 ~]$ 
    [gerrit@mt101 ~]$ sudo service nginx start
    Redirecting to /bin/systemctl start nginx.service
    [gerrit@mt101 ~]$
    
    


    通过yum安装GitWeb

    [gerrit@mt101 ~]$ sudo yum -y install gitweb
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    base                                                                          | 3.6 kB  00:00:00     
    extras                                                                        | 2.9 kB  00:00:00     
    mongodb-org-4.0                                                               | 2.5 kB  00:00:00     
    nginx-stable                                                                  | 2.9 kB  00:00:00     
    updates                                                                       | 2.9 kB  00:00:00     
    Resolving Dependencies
    --> Running transaction check
    ---> Package gitweb.noarch 0:1.8.3.1-20.el7 will be installed
    --> Finished Dependency Resolution
    ​
    Dependencies Resolved
    ​
    =====================================================================================================
     Package               Arch                  Version                       Repository           Size
    =====================================================================================================
    Installing:
     gitweb                noarch                1.8.3.1-20.el7                base                112 k
    ​
    Transaction Summary
    =====================================================================================================
    Install  1 Package
    ​
    Total download size: 112 k
    Installed size: 320 k
    Downloading packages:
    gitweb-1.8.3.1-20.el7.noarch.rpm                                              | 112 kB  00:00:07     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : gitweb-1.8.3.1-20.el7.noarch                                                      1/1 
      Verifying  : gitweb-1.8.3.1-20.el7.noarch                                                      1/1 
    ​
    Installed:
      gitweb.noarch 0:1.8.3.1-20.el7                                                                     
    ​
    Complete!
    [gerrit@mt101 ~]$
    
    

    3 - 设置projectroot目录

    配置文件:/etc/gitweb.conf 

    [gerrit@mt101 ~]$ sudo vim /etc/gitweb.conf
    [gerrit@mt101 ~]$ sudo cat /etc/gitweb.conf |grep -v "#" |grep -Ev "^$"
    our $projectroot = "/home/gerrit/gerrit_testsite/git"
    [gerrit@mt101 ~]$
    

    4 - 配置GitWeb的httpd服务

    4.1 配置GitWeb路径

    GitWeb是基于httpd服务工作的,配置文件:/etc/httpd/conf.d/git.conf

    [gerrit@mt101 ~]$ sudo cat /etc/httpd/conf.d/git.conf
    Alias /git /var/www/git
    ​
    <Directory /var/www/git>
      Options +ExecCGI
      AddHandler cgi-script .cgi
      DirectoryIndex gitweb.cgi
    </Directory>
    [gerrit@mt101 ~]$ 
    [gerrit@mt101 ~]$ sudo vim /etc/httpd/conf.d/git.conf
    [gerrit@mt101 ~]$ 
    [gerrit@mt101 ~]$ sudo cat /etc/httpd/conf.d/git.conf
    Alias /gitweb /var/www/git
    SetEnv GITWEB_CONFIG /etc/gitweb.conf
    <Directory /var/www/git>
      Options +ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
      AllowOverride All
      order allow,deny
      Allow from all
      AddHandler cgi-script .cgi
      DirectoryIndex gitweb.cgi
    </Directory>
    [gerrit@mt101 ~]$
    
    

    4.2 配置服务端口

    /etc/httpd/conf/httpd.conf中配置服务端口

    [gerrit@mt101 ~]$ sudo cat /etc/httpd/conf/httpd.conf |grep -v "#" |grep -Ev "^$" |grep -i listen
    Listen 80
    [gerrit@mt101 ~]$ 
    [gerrit@mt101 ~]$ sudo vim /etc/httpd/conf/httpd.conf
    [gerrit@mt101 ~]$ sudo cat /etc/httpd/conf/httpd.conf |grep -v "#" |grep -Ev "^$" |grep -i listen
    Listen 8084
    [gerrit@mt101 ~]$
    

    4.3 重启httpd服务

    [gerrit@mt101 ~]$ sudo systemctl restart httpd.service
    [gerrit@mt101 ~]$ sudo systemctl status httpd.service
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
       Active: active (running) since Tue 2019-12-10 22:57:22 CST; 9s ago
         Docs: man:httpd(8)
               man:apachectl(8)
      Process: 3432 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
     Main PID: 3439 (httpd)
       Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
        Tasks: 7
       CGroup: /system.slice/httpd.service
               ├─3439 /usr/sbin/httpd -DFOREGROUND
               ├─3440 /usr/sbin/httpd -DFOREGROUND
               ├─3441 /usr/sbin/httpd -DFOREGROUND
               ├─3442 /usr/sbin/httpd -DFOREGROUND
               ├─3443 /usr/sbin/httpd -DFOREGROUND
               ├─3444 /usr/sbin/httpd -DFOREGROUND
               └─3445 /usr/sbin/httpd -DFOREGROUND
    ​
    Dec 10 22:57:16 mt101 systemd[1]: Starting The Apache HTTP Server...
    Dec 10 22:57:21 mt101 httpd[3439]: AH00558: httpd: Could not reliably determine the server's f...sage
    Dec 10 22:57:22 mt101 systemd[1]: Started The Apache HTTP Server.
    Hint: Some lines were ellipsized, use -l to show in full.
    [gerrit@mt101 ~]$
    
    

    4.4 开放防火墙

    [gerrit@mt101 ~]$ sudo firewall-cmd --zone=public --permanent --add-port=8084/tcp
    success
    [gerrit@mt101 ~]$ sudo firewall-cmd --reload
    success
    [gerrit@mt101 ~]$ sudo firewall-cmd --list-all
    public (active)
      target: default
      icmp-block-inversion: no
      interfaces: enp0s3 enp0s8
      sources: 
      services: ssh dhcpv6-client
      ports: 8080/tcp 80/tcp 83/tcp 8083/tcp 8084/tcp
      protocols: 
      masquerade: no
      forward-ports: 
      source-ports: 
      icmp-blocks: 
      rich rules: 
        
    [gerrit@mt101 ~]$
    
    

    5 - 访问GitWeb

    6 - 和Gerrit集成

    6.1 更新Gerrit配置文件

    增加如下部分

    [gitweb]
           type = gitweb       
           cgi = /var/www/git/gitweb.cgi
    
    [gerrit@mt101 ~]$ sudo vim gerrit_testsite/etc/gerrit.config 
    [gerrit@mt101 ~]$ sudo cat gerrit_testsite/etc/gerrit.config 
    [gerrit]
        basePath = git
        canonicalWebUrl = http://192.168.16.101:8083/
        serverId = 0b911b9e-195a-46b0-a5cd-b407b776b344
    [container]
        javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
        javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
        user = root
        javaHome = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre
    [index]
        type = lucene
    [auth]
        type = HTTP
    [receive]
        enableSignedPush = false
    [sendemail]
        smtpServer = localhost
    [sshd]
        listenAddress = *:29418
    [httpd]
        listenUrl = http://192.168.16.101:8083/
    [cache]
        directory = cache
    [gitweb]
           type = gitweb       
           cgi = /var/www/git/gitweb.cgi
    [gerrit@mt101 ~]$ 
    
    

    6.2 修改git配置

    [gerrit@mt101 ~]$ git config --file /home/gerrit/gerrit_testsite/etc/gerrit.config gitweb.cgi /var/www/git/ gitweb.cgi
    [gerrit@mt101 ~]$ git config --file /home/gerrit/gerrit_testsite/etc/gerrit.config --unset gitweb.url
    [gerrit@mt101 ~]$
    

    6.3 重启Gerrit服务

    [gerrit@mt101 ~]$ sudo gerrit_testsite/bin/gerrit.sh restart
    Stopping Gerrit Code Review: OK
    Starting Gerrit Code Review: OK
    [gerrit@mt101 ~]$
    

    6.4 重新登录,确认GitWeb链接

    BROWSE---》Repositories---》Repository Browser---》gitweb链接

    点击All-Project的gitweb链接

    6.5 配置GitWeb访问权限

    默认只有Gerrit管理员用户才有GieWeb的访问权限。
    BROWSE---》Repositories---》All-Projects---》Access---》Reference: refs/meta/config

    在“refs/meta/config”的Read选项中添加“Registered Users”的ALLOW 权限

  • 相关阅读:
    MS CRM 2011的自定义和开发(11)——插件(plugin)开发(四)
    MS CRM 2011的自定义和开发(11)——插件(plugin)开发(一)
    MSCRM Plugin Debug
    MS CRM 2011的自定义和开发(11)——插件(plugin)开发(二)
    [转].net 使用NPOI或MyXls把DataTable导出到Excel
    HTML5的十大新特性
    语义化的HTML及其目的
    XHTML和HTML有什么区别
    浏览器根对象document之方法概述
    浏览器根对象document之数值和布尔属性
  • 原文地址:https://www.cnblogs.com/anliven/p/12008564.html
Copyright © 2011-2022 走看看