docker runs Gerrit (code review tool)

Keywords: Programming Docker git Google GitLab

What is gerrit?

Gerrit, a free, open source code review software, uses a web interface.

gerrit background

Gerrit, a free, open source code Code review software, using web interface. utilize Web browser , software programmers of the same team can review each other's modified program codes and decide whether they can submit, return or continue to modify them. Its use Git As the underlying version control system. It branches from Rietveld by Google Shawn Pearce was originally created to manage the Android program.

Software history

The name of the software comes from the Dutch designer Gerrit Rietveld. It was first created by Python Written in, after the second edition, changed to Java And SQL . Use Google Web Toolkit To generate front-end JavaScript.

gerrit can be a key part of continuous deployment, and it can be used with jenkins, gitlab's git services, and sonarqube code quality reporting aggregation tool.

gitlab installation tutorial: https://www.jianshu.com/p/c98e71ee7958

sonarqube installation tutorial: https://www.jianshu.com/p/9080642d4179

sonarqube tutorial: https://www.jianshu.com/p/f9d31148ce59

Using Docker to create Gerrit in production environment


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 create configuration file


[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 create configuration file

[ldap]
  password = secret

Initialize environment

1. Modify docker-compose.yml
Let go of the / entrypoint.sh init comment!

 

 
image.png

2. Execute command: docker compose up Gerrit

Background boot

1. Comment out the entry point: / entry point.sh init!

2. Re enter the command: docker compose up - D

Configure Gerrit's administrator account

  1. Visit: https:ip:6443

     
     
    image.png

2. login
Account number: cn=admin,dc=example,dc=org
Password: secret

3. Create a gerrit account
1. Click Create a child entry

 

 
image.png

2. Select account template

 

 
image.png

3. Fill in account information
The parameters are:
Given Name: Gerrit
Last Name: Admin
Common Name: Gerrit Admin
User ID: gerritadmin
Email: gerritadmin@localdomain
Password: secret

 
image.png

4. Commit the changes to LDAP

 
image.png

Log in to Gerrit

1. Enter address
My configured address is: http:ip:8010

 
image.png

2. login

 

 
image.png

3. Login succeeded

 
image.png

Here it is!

Personal wechat public, often update some practical dry goods:

 

 

Posted by richarro1234 on Fri, 07 Feb 2020 05:51:21 -0800