reference
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 |