이번 글에서는 Gerrit 3.1.10에서 Gerrit 3.5.1로의 이전에 관한 내용을 서술한다.

 

참고글은 다음과 같다

Gerrit 3.1.10 - 이전 설치 ( Migration, Docker )에서 작성한 내용과 아주 유사하다.

 

설치 준비

mkdir gerrit_3.5.1 && cd gerrit_3.5.1
touch docker-compose.yml

mkdir gerrit
cp -r $SRC/gerrit/cache gerrit
cp -r $SRC/gerrit/db gerrit
cp -r $SRC/gerrit/etc gerrit
cp -r $SRC/gerrit/git gerrit
cp -r $SRC/gerrit/index gerrit

mkdir httpd
cp $SRC/httpd/httpd.conf httpd   # 설정파일, 원래 장소에서 복사
cp $SRC/httpd/.htpasswd httpd    # 계정과 암호파일, 원래 장소에서 복사

노트:

  • plugins은 3.5.1용으로 설치하기 위해서 기존 백업데이터를 이용하지 않았다. 

 

file: docker-compose.yml

version: '3'

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

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

노트:

  • plugins은 3.5.1용으로 설치하기 위해서 기존 백업데이터를 이용하지 않았다. 즉, volumes 항목에서 제외하였다.
  • command: init 부분이 아주 중요하다. 이 부분이 없으면, 백업한 자료들을 모두 초기화한다. 기존 자료를 이용하여 초기화 하기 위해서는 주석을 풀고, 실행해주어야 한다. (1회성) 

 

file: gerrit/etc/gerrit.config

[gerrit]
        basePath = git
        canonicalWebUrl = http://localhost:8100/
        serverId = 5618f8c1-7707-41a7-be27-c2f23aa6790c
[index]
        type = lucene
[auth]
        type = http
        logoutUrl = http://aa:aa@localhost:8100/login
        trustContainerAuth = true  # remote로 plugin 설치위해
[receive]
        enableSignedPush = false
[sendemail]
        enable = true
        smtpServer = smtprelay.MYCOMPANY.COM
        smtpServerPort = 25
        smtpUser = SMTPUSER
        smtpPass = SMPTPASS
[user]
        email = no_reply@MYCOMPANY.COM
        anonymousCoward = COMPANY Gerrit
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = http://*:8080/
[cache]
        directory = cache
[commentLink "its-jira"]
        match = \\[([A-Z]+-[0-9]+)\\]
        html = <a href=\"https://jira.MYCOMPANY.COM/browse/$1\">[$1]</a>
        association = SUGGESTED
[its-jira]
        url = https://jira.MYCOMPANY
        username = JIRA-USER
        password = JIRA-PASS
[plugins]
        allowRemoteAdmin = true

 

file: gerrit/etc/its/actions.config

[rule "merged"]
    event-type = change-merged
    action = add-standard-comment

 

file: httpd/httpd.conf

...
LoadModule proxy_module modules/mod_proxy.so  # 주석제거
...
LoadModule proxy_http_module modules/mod_proxy_http.so # 주석제거
...

# 파일끝에 아래 추가
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<VirtualHost *>
    ServerName gerrit
    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
<Location "/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile '/usr/local/apache2/conf/.htpasswd'
Require valid-user
</Location>
AllowEncodedSlashes On
ProxyPass / http://gerrit:8080/ nocanon
</VirtualHost>

 

 

설치 실행

먼저 docker-compose.yml의 command 부분 주석을 제거하고 Gerrit의 초기화를 실행한다.

docker-compose up gerrit

Gerrit 3.1.10 초기화때와는 다르게, 초기화가 완료되면 자동 종료된다.

 

gerrit_1  | [2022-05-17 09:59:26,479] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin replication, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,480] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin codemirror-editor, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,481] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin gitiles, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,481] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin reviewnotes, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,482] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin download-commands, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,482] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin commit-message-length-validator, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,483] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin webhooks, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,483] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin avatars-gravatar, version 4d45f66597
gerrit_1  | [2022-05-17 09:59:26,483] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin delete-project, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,484] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin plugin-manager, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,484] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin singleusergroup, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,484] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin hooks, version v3.5.1
gerrit_1  | [2022-05-17 09:59:26,484] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Unloading plugin uploadvalidator, version v3.0.0-rc1-284-gefecf8cdf4
gerrit_1  | [2022-05-17 09:59:26,578] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_replication_220517_0958_9713708846942515415.jar
gerrit_1  | [2022-05-17 09:59:26,579] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_codemirror-editor_220517_0958_2369289632520411003.jar
gerrit_1  | [2022-05-17 09:59:26,579] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_gitiles_220517_0958_14918039203576338770.jar
gerrit_1  | [2022-05-17 09:59:26,579] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_reviewnotes_220517_0958_5216294365523276074.jar
gerrit_1  | [2022-05-17 09:59:26,579] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_download-commands_220517_0958_4264228789875070900.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_commit-message-length-validator_220517_0958_13705660632656731886.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_webhooks_220517_0958_13317217803860358281.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_avatars-gravatar_220517_0958_8896828478575643447.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_delete-project_220517_0958_10873195147850721930.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_plugin-manager_220517_0958_1093134940356759420.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_singleusergroup_220517_0958_9729983710349567030.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_hooks_220517_0958_4063223096168124260.jar
gerrit_1  | [2022-05-17 09:59:26,580] [main] INFO  com.google.gerrit.server.plugins.CleanupHandle : Cleaned plugin plugin_uploadvalidator_220517_0958_16440575924884005494.jar
gerrit_351_gerrit_1 exited with code 0

 

이후에 다시 docker-compose.yml의 command 부분을 주석처리하고 다시 Gerrit 및 httpd 서비스를 실행한다.

docker-compose up

 

이후에 Gerrit을 실행하면, 정상적으로 동작함을 확인할 수 있다.

플러그인 설치를 위해 Install plugins을 클릭하고, its-base와 its-jira를 설치해주었다. ( Jira와 Link 및 comment 추가를 위해 )

 

기존 이력도 확인할 수 있고, 좌측아래에서 버전이 3.5.1 임을 확인할 수 있다.

 

Gerrit와 Jira의 연계 테스트를 위해서 하나의 commit을 merge했더니, Jira에 comment가 잘 추가되었다.

 

 

 

'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 - 설치 ( Standalone )  (0) 2022.04.22
Gerrit - 설치 ( Quickstart )  (0) 2022.04.20

이 글에서는 기존에 설치되었던 Gerrit 3.1.10 (Docker)를 다른 곳으로 옮겨서 설치한 이력을 정리한다.

 

참고한 글은 다음과 같다.

 

기존에 Gerrit with HTTP authentication 을 참고로 하여, Gerrit 3.1.10을 설치하였다. (http 인증)

추후에 해당 서비스를 이전할 것을 대비하여, 이전 설치 방법을 정리한다.

 

설치 준비

mkdir gerrit_3.1.10 && cd gerrit_3.1.10
touch docker-compose.yml

mkdir gerrit
cp -r $SRC/gerrit/cache gerrit
cp -r $SRC/gerrit/db gerrit
cp -r $SRC/gerrit/etc gerrit
cp -r $SRC/gerrit/git gerrit
cp -r $SRC/gerrit/index gerrit
cp -r $SRC/gerrit/plugins gerrit

mkdir httpd
cp $SRC/httpd/httpd.conf httpd   # 설정파일, 원래 장소에서 복사
cp $SRC/httpd/.htpasswd httpd    # 계정과 암호파일, 원래 장소에서 복사

 

file: docker-compose.yml

version: '3'

services:
  gerrit:
    image: gerritcodereview/gerrit:3.1.10-ubuntu18
    user: root
    ports:
      - "29418:29418"
    volumes:
      - ./gerrit/db:/var/gerrit/db
      - ./gerrit/etc:/var/gerrit/etc
      - ./gerrit/git:/var/gerrit/git
      - ./gerrit/index:/var/gerrit/index
      - ./gerrit/plugins:/var/gerrit/plugins
    environment:
      - CANONICAL_WEB_URL=http://localhost:8100
        #    command: init

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

시행착오:

  • user: root 로 설정하지 않으면 초기화 과정 중에 에러가 발생한다. 이 에러는 docker내 계정과 호스트 계정과의 공유 디렉토리의 권한 문제인데, 여러가지 시도를 했으나 다른 방법을 찾지 못했다. 이렇게 설정하는 경우에 공유디렉토리 수정시에 sudo 명령으로만 가능하다.
  • 처음에는 gerrit/etc와 gerrit/git만 백업&복구하였으나, Review history등이 복구되지 않아서 나머지 디렉토리도 백업하였다.
  • plugins은 추후에 설치하려고 하였으나, Gerrit 3.1.10에서는 웹 인터페이스에서 설치가 되지 않아, 기존 백업에서 복사하였다.
  • command: init 부분이 아주 중요하다. 이 부분이 없으면, 백업한 자료들을 모두 초기화한다. 기존 자료를 이용하여 초기화 하기 위해서는 주석을 풀고, 실행해주어야 한다. (1회성) 

 

file: gerrit/etc/gerrit.config

[gerrit]
        basePath = git
        canonicalWebUrl = http://localhost:8100/
        serverId = 5618f8c1-7707-41a7-be27-c2f23aa6790c
[index]
        type = lucene
[auth]
        type = http
        logoutUrl = http://aa:aa@localhost:8100/login
        trustContainerAuth = true  # remote로 plugin 설치위해
[receive]
        enableSignedPush = false
[sendemail]
        enable = true
        smtpServer = smtprelay.MYCOMPANY.COM
        smtpServerPort = 25
        smtpUser = SMTPUSER
        smtpPass = SMPTPASS
[user]
        email = no_reply@MYCOMPANY.COM
        anonymousCoward = COMPANY Gerrit
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = http://*:8080/
[cache]
        directory = cache
[commentLink "its-jira"]
        match = \\[([A-Z]+-[0-9]+)\\]
        html = <a href=\"https://jira.MYCOMPANY.COM/browse/$1\">[$1]</a>
        association = SUGGESTED
[its-jira]
        url = https://jira.MYCOMPANY
        username = JIRA-USER
        password = JIRA-PASS
[plugins]
        allowRemoteAdmin = true

시행착오:

  • Gerrit이 초기화하면서 gerrit.config파일에 필요한 사항이 추가된다. 따라서 위에서 설정한 내용을 제외하고는 모두 삭제하였다. 예를 들면 container 섹션은 서버마다 다를 것이므로.
  • gerrit.serverId는 랜덤한 값인데, 새로 셋업하는 경우는 상관이 없지만, 백업&복구하는 경우에는 기존 값을 가져와야 한다. (Gerrit- Invalid Server Id when)
  • auth.trustContainerAuth = true로 설정하지 않으면, 웹 인터페이스에서 플러그인을 설치할 수가 없다. (  Plugin Manager Auth Issue, plugin-manager request different user/password? )
  • sendmail 섹션은 review시에 알림 메일을 보내기 위해 설정하였다.
  • commentLink 섹션은 git message에 Jira Issue의 Link를 생성하는 용도이다.
  • its-jira 섹션은 리뷰 후 merge시에 Jira Issue에 comment를 추가하는 용도이다. comment 추가 사항은 its/actions.config에서 설정한다.
  • plugins.allowRemoteAdmin = true 해주어야 웹 인터페이스에서 플러그인을 관리할 수 있다.

 

file: gerrit/etc/its/actions.config

[rule "merged"]
    event-type = change-merged
    action = add-standard-comment

 

 

다음은  Gerrit with HTTP authentication 에서 참고한 http 인증에 관한 설정이다.

해당 내용의 설명 처럼 아래 부분이 적용되어 있어야 한다.

 

file: httpd/httpd.conf

...
LoadModule proxy_module modules/mod_proxy.so  # 주석제거
...
LoadModule proxy_http_module modules/mod_proxy_http.so # 주석제거
...

# 파일끝에 아래 추가
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<VirtualHost *>
    ServerName gerrit
    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
<Location "/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
AuthUserFile '/usr/local/apache2/conf/.htpasswd'
Require valid-user
</Location>
AllowEncodedSlashes On
ProxyPass / http://gerrit:8080/ nocanon
</VirtualHost>

 

 

설치 실행

먼저 docker-compose.yml의 command 부분 주석을 제거하고 Gerrit의 초기화를 실행한다.

docker-compose up gerrit

 

초기화가 완료되면, 강제로 Ctrl+C으로 종료시킨다.

이후에 다시 docker-compose.yml의 command 부분을 주석처리하고 다시 Gerrit 및 httpd 서비스를 실행한다.

docker-compose up

이후에 Gerrit을 실행하면, 정상적으로 동작함을 확인할 수 있다.

 

Gerrit와 Jira의 연계 테스트를 위해서 하나의 commit을 merge했더니, Jira에 comment가 잘 추가되었다.

 

 

'Gerrit' 카테고리의 다른 글

Gerrit 3.1.10 -> 3.5.1 이전 설치 ( Migration, Docker )  (0) 2022.05.17
Gerrit 3.5.1 - 설치 ( Docker )  (0) 2022.05.11
Gerrit - LDAP 설정  (0) 2022.05.03
Gerrit - 설치 ( Standalone )  (0) 2022.04.22
Gerrit - 설치 ( Quickstart )  (0) 2022.04.20

여기에서는 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

Gerrit 공식 가이드

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

이 페이지의 설치 방법은 공식 가이드 중 Qucickstart for Installing Gerrit on Linux 을 따른다.

Quickstart 설치는 Gerrit을 간단히 설치하고 맛보는 용도이다.

 

Gerrit 설치

Gerrit 다운로드

Gerrit 설치를 위해서 먼저 다운로드를 받아야 한다.

여기에서 다운로드된 Gerrit 버전이 설치 디렉토리에 복사되므로, 최신 버전인 3.5.1을 다운로드 받았다.

junggu.lee@bungslxubu51:~$ cd bin
junggu.lee@bungslxubu51:~/bin$ wget https://gerrit-releases.storage.googleapis.com/gerrit-3.5.1.war

 

Gerrit 설치 명령어

Quickstart 가이드 문서처럼 --batch --dev -d 옵션을 사용하면, 기본설정을 기본으로 가정하고 빠르게 설치가 가능하다.

Quickstart 가이드 문서에서 사용하는 옵션은 다음과 같다.

  • --batch : 기본 구성 옵션을 사용
  • --dev : 인증시 DEVELOPMENT_BECOME_ANY_ACCOUNT 을 사용
  • -d : 설치할 디렉토리 지정
junggu.lee@bungslxubu51:~$ java -jar ~/bin/gerrit-3.5.1.war init --batch --dev -d ~/work/gerrit_quickstart

설치 후 자동으로 Gerrit이 실행되며, Web Browser에서 Gerrit 창이 열린다.

 

설정 문제가 있는 경우에, 실행시 에러가 발생할 수 있다.

이 때는 로그 파일을 살펴보고, 설정 파일인 etc/gerrit.config을 수정하여 Gerrit을 실행하면 된다.

내 경우에는 8080 포트의 충돌로 인해서 에러가 발생하였다. ( 문제가 발생했을때는 etc/logs/error_log 파일로 확인 가능하다 )

etc/gerrit.configgerrit.canonicalWebUrlhttpd.listenUrl 의 8080을 8081로 변경하였다.

[gerrit]
        basePath = git
        canonicalWebUrl = http://bungslxubu51:8081/
        serverId = c5b60791-8a32-4d6f-850e-4698ef8ddde9
[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 = junggu.lee
        javaHome = /usr/lib/jvm/java-11-openjdk-amd64
[index]
        type = lucene
[auth]
        type = DEVELOPMENT_BECOME_ANY_ACCOUNT
        userNameCaseInsensitive = true
[receive]
        enableSignedPush = false
[sendemail]
        smtpServer = localhost
[sshd]
        listenAddress = *:29418
[httpd]
        listenUrl = http://*:8081/
[cache]
        directory = cache
[plugins]
        allowRemoteAdmin = true

이후에 다시 Gerrit을 실행한다.

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

 

또 다른 방법으로는 기본값으로 설정하는 옵션인 --batch 을 제거하면 각종 설정을 개별적으로 지정할 수 있다. ( Standalone 설치 ) 

내 경우에 8080 포트 충돌을 피하기 위해, Listen on port 부분을 8081 포트로 설정하고, 나머지 설정은 기본값으로 두었다.

junggu.lee@bungslxubu51:~$ java -jar ~/bin/gerrit-3.5.1.war init -d $GERRIT_SITE
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2022-04-20 04:52:39,628] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /home/junggu.lee/work/gerrit_quickstart/etc/gerrit.config; assuming defaults

*** Gerrit Code Review 3.5.1
***

Create '/home/junggu.lee/work/gerrit_quickstart' [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_quickstart/bin/gerrit.war [Y/n]?
Copying gerrit-3.5.1.war to /home/junggu.lee/work/gerrit_quickstart/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]?
Install plugin commit-message-length-validator version v3.5.1 [y/N]?
Install plugin delete-project version v3.5.1 [y/N]?
Install plugin download-commands version v3.5.1 [y/N]?
Install plugin gitiles version v3.5.1 [y/N]?
Install plugin hooks version v3.5.1 [y/N]?
Install plugin plugin-manager version v3.5.1 [y/N]?
Install plugin replication version v3.5.1 [y/N]?
Install plugin reviewnotes version v3.5.1 [y/N]?
Install plugin singleusergroup version v3.5.1 [y/N]?
Install plugin webhooks version v3.5.1 [y/N]?
Initializing plugins.
No plugins found with init steps.

============================================================================
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_quickstart
Init complete, reindexing accounts,changes,groups,projects with: reindex --site-path /home/junggu.lee/work/gerrit_quickstart --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 (6.3/s)
Index groups in version 8 is ready
Reindexing changes: Slicing projects: 100% (2/2), done
Reindexed 0 documents in changes index in 0.0s (0.0/s)
Index changes in version 71 is ready
Reindexing projects:    100% (2/2)
Reindexed 2 documents in projects index in 0.0s (40.8/s)
Index projects in version 4 is ready
Executing /home/junggu.lee/work/gerrit_quickstart/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_quickstart/bin/gerrit.sh not being run as root.
         Consider changing the OOM score adjustment manually for Gerrit's PID=870815 with e.g.:
         echo '-1000' | sudo tee /proc/870815/oom_score_adj
OK
Waiting for server on bungslxubu51:8081 ... OK
Opening http://bungslxubu51:8081/#/admin/projects/ ...OK

 

그리고 내부 테스트를 목적으로 하는 경우, 외부에서 Gerrit에 접속하는 것을 막을 수 있다.

이 경우, etc/gerrit.conifg 파일의 httpd.listenUrllocalhost로 수정하면 된다. ( Gerrit의 Quickstart 문서 참조 )

# 중략
[httpd]
        listenUrl = http://localhost:8081/
# 중략

Gerrit 실행

Gerrit 설치가 성공적으로 실행되면, 자동으로 Web Browser로 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.+  737432  707297  0 02:46 pts/0    00:00:00 grep --color=auto gerrit

설치 디렉토리를 제거한다.

junggu.lee@bungslxubu51:~$ rm -rf work/gerrit_quickstart/

 

Troubleshooting

Gerrit에 문제가 생겼을때는 에러 로그를 살펴본다. 에러 로그는 logs/error_log 이다.

다음은 내 에러 및 처리하는 과정을 표시하였다.

junggu.lee@bungslxubu51:~$ cat ~/work/gerrit_quickstart/logs/error_log
[2022-04-20T02:39:01.669Z] [main] INFO  com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SshCommandStart' queue
[2022-04-20T02:39:02.037Z] [main] INFO  com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SSH-Stream-Worker' queue
[2022-04-20T02:39:02.039Z] [main] INFO  com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SSH-Interactive-Worker' queue
[2022-04-20T02:39:02.039Z] [main] INFO  com.google.gerrit.server.git.WorkQueue : Adding metrics for 'SSH-Batch-Worker' queue
[2022-04-20T02:39:02.040Z] [main] INFO  com.google.gerrit.server.git.WorkQueue : Adding metrics for 'MigrateExternalIdCase' queue
[2022-04-20T02:39:02.052Z] [main] WARN  com.google.gerrit.server.config.GitwebCgiConfig : gitweb not installed (no /usr/lib/cgi-bin/gitweb.cgi found)
[2022-04-20T02:39:02.726Z] [main] INFO  org.eclipse.jetty.util.log : Logging initialized @5624ms to org.eclipse.jetty.util.log.Slf4jLog
[2022-04-20T02:39:02.854Z] [main] INFO  com.google.gerrit.server.git.SystemReaderInstaller : Set JGit's SystemReader to read system config from /home/junggu.lee/work/gerrit_quickstart/etc/jgit.config
[2022-04-20T02:39:02.858Z] [main] INFO  com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 1001m
[2022-04-20T02:39:03.261Z] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /home/junggu.lee/work/gerrit_quickstart/plugins
[2022-04-20T02:39:03.275Z] [main] INFO  com.google.gerrit.server.config.ScheduleConfig : No schedule configuration for "accountDeactivation".
[2022-04-20T02:39:03.313Z] [main] INFO  com.google.gerrit.sshd.SshDaemon : Started Gerrit APACHE-SSHD-2.6.0 on *:29418
[2022-04-20T02:39:03.316Z] [main] INFO  org.eclipse.jetty.server.Server : jetty-9.4.36.v20210114; built: 2021-01-14T16:44:28.689Z; git: 238ec6997c7806b055319a6d11f8ae7564adc0de; jvm 11.0.14.1+1-Ubuntu-0ubuntu1.20.04
[2022-04-20T02:39:03.342Z] [main] INFO  org.eclipse.jetty.server.session : DefaultSessionIdManager workerName=node0
[2022-04-20T02:39:03.343Z] [main] INFO  org.eclipse.jetty.server.session : No SessionScavenger set, using defaults
[2022-04-20T02:39:03.344Z] [main] INFO  org.eclipse.jetty.server.session : node0 Scavenging every 600000ms
[2022-04-20T02:39:03.407Z] [main] INFO  org.eclipse.jetty.server.handler.ContextHandler : Started o.e.j.s.ServletContextHandler@75452b01{/,null,AVAILABLE}
[2022-04-20T02:39:03.412Z] [main] ERROR com.google.gerrit.pgm.Daemon : Unable to start daemon
java.lang.IllegalStateException: Cannot start HTTP daemon
        at com.google.gerrit.pgm.http.jetty.JettyServer$Lifecycle.start(JettyServer.java:109)
        at com.google.gerrit.lifecycle.LifecycleManager.start(LifecycleManager.java:95)
        at com.google.gerrit.pgm.Daemon.start(Daemon.java:386)
        at com.google.gerrit.pgm.Daemon.run(Daemon.java:285)
        at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:61)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:224)
        at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:120)
        at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:65)
        at Main.main(Main.java:28)
Caused by: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8080
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.server.Server.doStart(Server.java:401)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at com.google.gerrit.pgm.http.jetty.JettyServer$Lifecycle.start(JettyServer.java:95)
        ... 12 more
Caused by: java.net.BindException: Address already in use
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:459)
        at java.base/sun.nio.ch.Net.bind(Net.java:448)
        at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
        at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
        ... 19 more

Gerrit에서는 기본 설치시에 8080포트를 사용하는데, 이미 8080포트를 사용하고 있어서 사용할 수가 없다.

8080 포트가 사용되고 있는지 확인해보았다.

junggu.lee@bungslxubu51:~$ netstat -nap | grep 8080
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:58080         127.0.0.1:9099          TIME_WAIT   -

Gerrit의 동작을 확인하기 위해서 가벼운 브라우저 ( light web browser )인 midori를 설치했는데, 이 midori에서 8080 포트를 사용하고 있었다.

Gerrit 설치시에 8081 포트를 사용하도록 재설치하여 문제를 해결하였다.

 

 

'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 - 설치 ( Standalone )  (0) 2022.04.22
Gerrit 변경사항을 적용하기  (0) 2021.11.18

reference

 

Gerrit Trigger

This plugin integrates with <a href="http://code.google.com/p/gerrit/" target="_blank" rel="nofollow noopener noreferrer">Gerrit</a> code review.

plugins.jenkins.io

 

Gerrit Trigger Plugin을 이용하여, Review commit이 올라올때 마다 Jenkins를 이용하여 빌드를 하였다.

이 때, 변경사항을 다음과 같은 방식으로 적용하였다.

cd vendor/google/tv/broadcaststack
git fetch "ssh://gerrit@gerrit.mycompany.net:29418/broadcaststack" ${GERRIT_REFSPEC} && git checkout FETCH_HEAD

 

그런데, 하나의 저장소에 대해서는 잘 동작하였으나, 여러 개의 저장소의 변경사항에 대해서는 위와 같은 방식이 적절하지 않았다. 즉, 변경사항을 추적할 저장소는 broadcaststack, projects/apple 이었는데, Jenkins script에서는 어느 저장소의 Patchset을 적용할지 ( 어느 디렉토리안에서 get fetch를 사용할지 ) 확인할 수 가 없었다.

 

Gerrit Trigger 플러그인 홈페이지에는 다음과 같은 예제가 있었다. 

repo init -u git://gerrit.mycompany.net/mymanifest.git
repo sync
repo download $GERRIT_PROJECT $GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER

그런데, repo download 명령어는 이전에 사용한 경험이 없어서, help를 찾아보았다.

$ repo help download

Summary

Download and checkout a change

Usage: repo download {[project] change[/patchset]}...

Options:
  -h, --help         show this help message and exit
  -c, --cherry-pick  cherry-pick instead of checkout
  -r, --revert       revert instead of checkout
  -f, --ff-only      force fast-forward merge

Description

The 'repo download' command downloads a change from the review system
and makes it available in your project's local working directory. If no
project is specified try to use current directory as a project.

약간의 시행착오 끝에, 다음과 같이 사용 방법을 확인할 수 있었다.

아래 코드에서 broadcaststack은 저장소 이름이고, 934/9에서 934는 Gerrit의 Change number(리뷰요청번호), 9는 Patchset number 이다.

$ repo download broadcaststack 934/9
From ssh://gerrit.mycompany.net:29418/broadcaststack
 * branch              refs/changes/34/934/9 -> FETCH_HEAD
HEAD is now at 49a307e6 test

 

Jenkins script에서 특정 디렉토리로 이동해서 git fetch하던 방식을, 훨씬 단순하고도 직관적으로 개선할 수 있었다.

그리고, 다시 Patchset을 적용하기 전으로 돌아가기 위해서는 단순히 repo sync를 해주면 되었다.

# AS-IS
cd vendor/google/tv/broadcaststack
git fetch "ssh://gerrit@gerrit.mycompany.net:29418/broadcaststack" ${GERRIT_REFSPEC} && git checkout FETCH_HEAD


# TO-BE
repo download $GERRIT_PROJECT $GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER

 

'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 - 설치 ( Standalone )  (0) 2022.04.22
Gerrit - 설치 ( Quickstart )  (0) 2022.04.20

+ Recent posts