여기에서는 Docker를 이용하여 Gerrit 3.5.1 설치하는 방법을 설명한다.

 

설치를 위해 참고한 사이트는 다음과 같다.

 

mkdir gerrit httpd
mkdir gerrit/etc

 

file: docker-compose.yml

version: '3'

services:
  gerrit:
    image: gerritcodereview/gerrit:3.5.1-ubuntu20
    user: root
    ports:
      - "29418:29418"
    volumes:
      - ./gerrit/etc:/var/gerrit/etc
    environment:
      - CANONICAL_WEB_URL=http://localhost:8100
    command: init   # Note 1

  apache:
    image: httpd
    volumes:
      - ./httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf
      - ./httpd/.htpasswd:/usr/local/apache2/conf/.htpasswd
    ports:
       - "8100:80"

 

file: gerrit/etc/gerrit.config

[gerrit]
  basePath = git

[index]
  type = LUCENE

[auth]
  type = http
  logoutUrl = http://aa:aa@localhost:8100/logout

[sendemail]
  smtpServer = localhost

[sshd]
  listenAddress = *:29418

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

[cache]
  directory = cache

[plugins]
  allowRemoteAdmin = true

Gerrit 초기화를 위해 다음 명령을 실행한다. 초기화 이후에 자동으로 종료된다.

docker-compose up gerrit

초기화가 끝나면, docker-compose.yml 내의 'command: init'을 주석처리한다.

 

그리고 gerrit.config을 살펴보면, 필요한 속성이 추가되었음을 확인할 수 있다.

 

Gerrit과 Apache를 같이 실행한다.

docker-compose up

실행 후 표시되는 로그 화면에서 'Gerrit Code Review 3.5.1 ready'이 나오면 정상적으로 실행된 것이다.

 

gerrit_1  | [2022-05-11T04:58:10.069Z] [main] INFO  org.eclipse.jetty.server.handler.ContextHandler : Started o.e.j.s.ServletContextHandler@41e35358{/,null,AVAILABLE}
gerrit_1  | [2022-05-11T04:58:10.081Z] [main] INFO  org.eclipse.jetty.server.AbstractConnector : Started ServerConnector@f1d5f3{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
gerrit_1  | [2022-05-11T04:58:10.082Z] [main] INFO  org.eclipse.jetty.server.Server : Started @7894ms
gerrit_1  | [2022-05-11T04:58:10.084Z] [main] INFO  com.google.gerrit.pgm.Daemon : Gerrit Code Review 3.5.1 ready

 

브라우저에서 http://localhost:8100 을 열면 Gerrit에 접근할 수 있다.

 

References

Gerrit은 계정에 대한 인증 ( Authentication )을 직접 처리하지 않는다.

따라서 로그인을 위해서는 인증에 관한 별도 처리가 필요하다.

 

처음 Gerrit을 설치했을때는 HTTP 인증 ( Apache )을 통해 로그인을 진행하도록 했었다. 별도의 파일에 아이디와 계정을 처리했기 때문에 가장 단순했기 때문이다. 그러나 나는 Apache에 대한 지식도 없고, Gerrit 이외에 Apache를 신경쓰는게 부담이 되었기 때문에 인증 방식을 LDAP으로 처리해보았다.

 

그런데, 나는 LDAP에 대한 지식도 없었고, 회사내 LDAP 서버 정보도 그다지 많지 않았다.

사내 Jenkins와 Artifactory의 설정에 LDAP 정보가 있었고, 사내 Confluence에 LDAP 관련 내용이 있었으나 확실한 정보는 아니었다. 다만 이러한 정보를 바탕으로 여러가지 시도 끝에, LDAP 서버 정보과 검색을 할 수 있었다. 

 

우선 Softerra LDAP Browser ( https://www.ldapadministrator.com/softerra-ldap-browser.htm ) 을 통해 내 LDAP서버에 대한 정보를 확인하였고, 다음을 조건으로 검색하여 사용자를 찾을 수 있었다. 

 

(&(objectClass=person)(sAMAccountName=<Service계정>))

(&(objectClass=person)(sAMAccountName=<나의 AD계정>)

(&(objectClass=person)(mail=junggu.lee@mycompany.com))

그리고 Search하여 나온 결과 항목을 더블클릭하면 자신에 대한 상세 정보를 확인할 수 있다.

 

 

이상의 LDAP 정보를 이용하여, etc/gerrit.config 파일의 일부 설정을 다음과 같이 변경하였다.

username과 password는 LDAP의 사용자를 확인하기 위해서 필요한데, 내 경우에는 AD계정이 아니라, 이메일주소일때만 정상적으로 동작하였다.

 

Gerrit의 Config 설정 문서에는 많은 속성값을 설정할 수 있다.

그런데, 대부분은 디폴트값으로 진행 할 수 있었고, 단지 4항목에 대해서만 설정해주면 되었다.

[auth]
        type = LDAP
[ldap]
        server = ldap://MYCOMPANY.com:3268
        accountBase = dc=MYCOMPANY, dc=com

        username = admin@MYCOMPANY.com
        password = PASSWORD

 

 

로그인 후에 Settings를 확인하면, 별도 입력하지 않았음에도 이름과 이메일이 설정되어 있다.

'Gerrit' 카테고리의 다른 글

Gerrit 3.1.10 - 이전 설치 ( Migration, Docker )  (0) 2022.05.16
Gerrit 3.5.1 - 설치 ( Docker )  (0) 2022.05.11
Gerrit - 설치 ( Standalone )  (0) 2022.04.22
Gerrit - 설치 ( Quickstart )  (0) 2022.04.20
Gerrit 변경사항을 적용하기  (0) 2021.11.18

Gerrit 공식 가이드

Gerrit의 공식 가이드는 https://www.gerritcodereview.com/ 상단의 Docs > Latest 에서 볼 수 있다.

이 페이지의 설치 방법은 공식 가이드 중 Standalone Daemon Installation Guide을 따른다.

Standalone설치는 Gerrit의 정식 설치 방법이다. 

 

Gerrit 설치

Standalone 설치는 Quickstart 설치와 거의 동일하다.

다만 실행 옵션 중 기본값을 사용하는 --batch--dev을 제외하고 실행한다.

실행 후 대부분의 옵션을 기본값을 사용하였으나, 다음값은 변경하여 적용하였다.

  • Listen on port : 8080 -> 8081로 변경
  • Canonical URL : Gerrit에 접속하기 위한 URL. 만약 외부 접속을 막고 싶다면, 호스트이름을 localhost로 변경한다. 아래 예에서 처럼 'bungslxubu51'의 경우는, 외부에서 접속이 되지 않을 수 있다.
  • Plugins : 모든 플러그인을 설치하기 위해 'Y'로 입력
junggu.lee@bungslxubu51:~$ java -jar ~/bin/gerrit-3.5.1.war init -d ~/work/gerrit_standalone
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2022-04-22 07:30:56,181] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /home/junggu.lee/work/gerrit_standalone/etc/gerrit.config; assuming defaults

*** Gerrit Code Review 3.5.1
***

Create '/home/junggu.lee/work/gerrit_standalone' [Y/n]?

*** Git Repositories
***

Location of Git repositories   [git]:

*** JGit Configuration
***

Auto-configured "receive.autogc = false" to disable auto-gc after git-receive-pack.

*** Index
***

Type                           [lucene]:

*** User Authentication
***

Authentication method          [openid/?]:
Enable signed push support     [y/N]?
Use case insensitive usernames [Y/n]?

*** Review Labels
***

Install Verified label         [y/N]?

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [none/?]:
SMTP username                  :

*** Container Process
***

Run as                         [junggu.lee]:
Java runtime                   [/usr/lib/jvm/java-11-openjdk-amd64]:
Copy gerrit-3.5.1.war to /home/junggu.lee/work/gerrit_standalone/bin/gerrit.war [Y/n]?
Copying gerrit-3.5.1.war to /home/junggu.lee/work/gerrit_standalone/bin/gerrit.war

*** SSH Daemon
***

Listen on address              [*]:
Listen on port                 [29418]:
Generating SSH host key ... rsa... 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]: 8081
Canonical URL                  [http://bungslxubu51:8081/]:

*** Cache
***


*** Plugins
***

Installing plugins.
Install plugin codemirror-editor version v3.5.1 [y/N]? y
Installed codemirror-editor v3.5.1
Install plugin commit-message-length-validator version v3.5.1 [y/N]? y
Installed commit-message-length-validator v3.5.1
Install plugin delete-project version v3.5.1 [y/N]? y
Installed delete-project v3.5.1
Install plugin download-commands version v3.5.1 [y/N]? y
Installed download-commands v3.5.1
Install plugin gitiles version v3.5.1 [y/N]? y
Installed gitiles v3.5.1
Install plugin hooks version v3.5.1 [y/N]? y
Installed hooks v3.5.1
Install plugin plugin-manager version v3.5.1 [y/N]? y
Installed plugin-manager v3.5.1
Install plugin replication version v3.5.1 [y/N]? y
Installed replication v3.5.1
Install plugin reviewnotes version v3.5.1 [y/N]? y
Installed reviewnotes v3.5.1
Install plugin singleusergroup version v3.5.1 [y/N]? y
Installed singleusergroup v3.5.1
Install plugin webhooks version v3.5.1 [y/N]? y
Installed webhooks v3.5.1
Initializing plugins.

============================================================================
Welcome to the Gerrit community

Find more information on the homepage: https://www.gerritcodereview.com
Discuss Gerrit on the mailing list: https://groups.google.com/g/repo-discuss
============================================================================
Initialized /home/junggu.lee/work/gerrit_standalone
Init complete, reindexing accounts,changes,groups,projects with: reindex --site-path /home/junggu.lee/work/gerrit_standalone --threads 1 --index accounts --index changes --index groups --index projects --disable-cache-statsReindexed 0 documents in accounts index in 0.0s (0.0/s)
Index accounts in version 11 is ready
Reindexing groups:      100% (2/2)
Reindexed 2 documents in groups index in 0.3s (5.8/s)
Index groups in version 8 is ready
Reindexing changes: Slicing projects: 100% (2/2), done
Reindexed 0 documents in changes index in 0.5s (0.0/s)
Index changes in version 71 is ready
Reindexing projects:    100% (2/2)
Reindexed 2 documents in projects index in 0.1s (35.7/s)
Index projects in version 4 is ready
Executing /home/junggu.lee/work/gerrit_standalone/bin/gerrit.sh start
Starting Gerrit Code Review: WARNING: Could not adjust Gerrit's process for the kernel's out-of-memory killer.
         This may be caused by /home/junggu.lee/work/gerrit_standalone/bin/gerrit.sh not being run as root.
         Consider changing the OOM score adjustment manually for Gerrit's PID=4136478 with e.g.:
         echo '-1000' | sudo tee /proc/4136478/oom_score_adj
OK
Waiting for server on bungslxubu51:8081 ... OK
Opening http://bungslxubu51:8081/#/admin/projects/ ...OK

설치 후 자동으로 Web Browser로 Gerrit이 열린다.

 

Gerrit 실행/중지/재실행

Gerrit을 실행/중지/재실행은 다음 명령으로 가능하다.

junggu.lee@bungslxubu51:~$ cd work/gerrit_quickstart/bin/
junggu.lee@bungslxubu51:~/work/gerrit_quickstart/bin$ gerrit.sh start
junggu.lee@bungslxubu51:~/work/gerrit_quickstart/bin$ gerrit.sh stop
junggu.lee@bungslxubu51:~/work/gerrit_quickstart/bin$ gerrit.sh restart

 

 

Gerrit 삭제

우선 Gerrit을 중지한 이후에, 실행 중인 프로세스를 확인 후에 설치 디렉토리를 삭제하면 된다.

junggu.lee@bungslxubu51:~$ work/gerrit_quickstart/bin/gerrit.sh stop
junggu.lee@bungslxubu51:~$ ps -ef | grep gerrit
junggu.lee@bungslxubu51:~$ rm -rf work/gerrit_quickstart/

 

Gerrit 설정 변경

Gerrit 설정을 변경하고자 할때는 etc/gerrit.config 파일을 수정한 이후에 재시작을 한다.

 

 

관리자 계정

Gerrit에서는 최초 로그인하는 사용자가 관리자 ( Administrator )가 된다.

 

Troubleshooting

문제가 발생하면 logs/error_log 파일을 확인한다.

'Gerrit' 카테고리의 다른 글

Gerrit 3.1.10 - 이전 설치 ( Migration, Docker )  (0) 2022.05.16
Gerrit 3.5.1 - 설치 ( Docker )  (0) 2022.05.11
Gerrit - LDAP 설정  (0) 2022.05.03
Gerrit - 설치 ( Quickstart )  (0) 2022.04.20
Gerrit 변경사항을 적용하기  (0) 2021.11.18

+ Recent posts