docker運行gerrit(代碼審查工具)


gerrit是什么?

Gerrit,一種免費、開放源代碼的代碼審查軟件,使用網頁界面。

gerrit背景

Gerrit,一種免費、開放源代碼的代碼審查軟件,使用網頁界面。利用網頁瀏覽器,同一個團隊的軟件程序員,可以相互審閱彼此修改后的程序代碼,決定是否能夠提交,退回或者繼續修改。它使用Git作為底層版本控制系統。它分支自Rietveld,作者為Google公司的Shawn Pearce,原先是為了管理Android計划而產生。

軟件歷史

這個軟件的名稱,來自於荷蘭設計師赫里特·里特費爾德(Gerrit Rietveld)。最早它是由Python寫成,在第二版后,改成用JavaSQL。使用Google Web Toolkit來產生前端的JavaScript

gerrit可以組成持續部署關鍵性的一環,和jenkins,gitlab的git服務組成,還可以與sonarqube代碼質量報告聚合工具一起使用。

gitlab安裝教程: https://www.jianshu.com/p/c98e71ee7958

sonarqube安裝教程: https://www.jianshu.com/p/9080642d4179

sonarqube使用教程: https://www.jianshu.com/p/f9d31148ce59

在生產環境中使用Docker創建Gerrit


version: '3'
services:
  gerrit:
    image: gerritcodereview/gerrit
    ports:
      - "29418:29418"
      - "8010:8080"
    depends_on:
      - ldap
    volumes:
      - /usr/local/docker/gerrit/etc:/var/gerrit/etc
      - /usr/local/docker/gerrit/git:/var/gerrit/git
      - /usr/local/docker/gerrit/db:/var/gerrit/db
      - /usr/local/docker/gerrit/index:/var/gerrit/index
      - /usr/local/docker/gerrit/cache:/var/gerrit/cache
    environment:
      - CANONICAL_WEB_URL=http://localhost
    #entrypoint: /entrypoint.sh init
  ldap:
    image: osixia/openldap
    ports:
      - "389:389"
      - "636:636"
    environment:
      - LDAP_ADMIN_PASSWORD=secret
    volumes:
      - /usr/local/docker/gerrit/ldap/var:/var/lib/ldap
      - /usr/local/docker/gerrit/ldap/etc:/etc/ldap/slapd.d
  ldap-admin:
    image: osixia/phpldapadmin
    ports:
      - "6443:443"
    environment:
      - PHPLDAPADMIN_LDAP_HOSTS=ldap


/usr/local/docker/gerrit/etc/gerrit.config 創建配置文件


[gerrit]
  basePath = git
  canonicalWebUrl = http://localhost

[index]
  type = LUCENE

[auth]
  type = ldap
  gitBasicAuth = true

[ldap]
  server = ldap://ldap
  username=cn=admin,dc=example,dc=org
  accountBase = dc=example,dc=org
  accountPattern = (&(objectClass=person)(uid=${username}))
  accountFullName = displayName
  accountEmailAddress = mail

[sendemail]
  smtpServer = localhost

[sshd]
  listenAddress = *:29418

[httpd]
  listenUrl = http://*:8080/

[cache]
  directory = cache

[container]
  user = root

/usr/local/docker/gerrit/etc/secure.config 創建配置文件

[ldap]
  password = secret

初始化環境

1.修改docker-compose.yml
把#entrypoint: /entrypoint.sh init注釋放開!
image.png

2.執行命令: docker-compose up gerrit

后台啟動

1.把#entrypoint: /entrypoint.sh init注釋掉!

2.再輸入命令: docker-compose up -d

配置Gerrit的管理員賬號

  1. 訪問:https:ip:6443
    image.png

2.登錄
賬號:cn=admin,dc=example,dc=org
密碼:secret

3.創建gerrit賬號
1.點擊Create a child entry
image.png

2.選擇賬號模板
image.png

3.填入賬號信息
參數為:
Given Name: Gerrit
Last Name: Admin
Common Name: Gerrit Admin
User ID: gerritadmin
Email: gerritadmin@localdomain
Password: secret

image.png

4.提交到LDAP (commit the changes to LDAP)

image.png

登錄 Gerrit

1.輸入地址
我這邊配置的地址是:http:ip:8010

image.png

2.登錄
image.png

3.登錄成功

image.png

到這了就成功了!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM