Overview
지속적인 통합(Continuous Integration, CI)은 단순한 빌드와 테스트를 넘어, 다양한 업무를 자동화하는 강력한 도구이다. 그 중 하나가 바로 GitLab CI를 활용해 Google Drive에 파일을 자동 업로드하는 작업이다.
이 방법은 다음과 같은 상황에서 유용하다.
- 빌드 결과물을 팀 공유용 Google Drive에 자동 저장
- 테스트 리포트나 로그 파일을 백업 용도로 업로드
- 특정 시점의 아티팩트를 수동 없이 전달하고 보관
이 글에서는 GitLab CI에서 rclone을 활용하여 회사의 Google Workspace 공유 계정의 Google Drive에 파일을 업로드하는 방법을 소개한다.
특히 디자인 문서나 산출물을 팀 Drive에 자동으로 올려야 하는 프로젝트에 매우 적합한 방식이다.

1. rclone 설정
우선, rclone을 로컬에서 설정하고, 설정 파일을 GitLab에 업로드해야 한다.
Google Workspace 공유 계정 준비
- 회사에서 사용하는 Google Workspace 계정으로 로그인
- Google Drive 내 공유 드라이브 또는 특정 폴더 생성
- rclone 인증을 위한 서비스 계정 또는 OAuth 인증을 마치고 토큰 저장
rclone 설치
# Linux
curl https://rclone.org/install.sh | sudo bash
# Mac
brew install rclone
rclone 설정 예시
rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
...
name> somaz
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
...
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
(...)
15 / Google Drive
\ "drive"
(...)
Storage> drive
...
Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id>
...
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
...
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"
scope> drive
...
Enter a string value. Press Enter for the default ("").
root_folder_id>
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
...
Enter a string value. Press Enter for the default ("").
service_account_file>
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n>
...
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> y
...
Configure this as a team drive?
y) Yes
n) No (default)
y/n> y
--------------------
[gdrive]
type = drive
scope = drive
token = {"access_token": 토큰값"}
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
- API를 이용하실 분들은 http://cloud.google.com 접속해서 발급하시면 된다.
- 공유 드라이브를 사용하려면 team drive 설정 할때 y 눌러야 한다.
`rclone.conf` 예시
[Name]
type = drive
scope = drive
token = {"access_token":"ya29.a...","expiry":"2025-07-08T16:48:22.410283+09:00","expires_in":3599}
team_drive = 0AH...
root_folder_id =
team_drive 값은 공유 드라이브를 사용할 때 필요하다. 개인 My Drive만 사용할 경우 생략한다.
OAuth 인증 등 안내에 따라 Google 계정 연동을 마치면 `~/.config/rclone/rclone.conf` 파일이 생성된다.
2. GitLab CI 설정
이제 위에서 생성한 rclone.conf 파일을 GitLab에 등록하고 `.gitlab-ci.yml` 에 업로드 작업을 정의합니다.
GitLab 변수 등록
Settings > CI/CD > Variables 에서 다음과 같이 등록한다.
- Key: RCLONE_CONFIG
- Type: File
- Value: `rclone.conf` 파일 내용 업로드
- Flags:
- Mask variable (선택)
- Expand variable reference (필수)
`gitlab-ci.yml` 예시
stages:
- gdrive-upload
variables:
CONFIG: $RCLONE_CONFIG
.change_files: &change_files
changes:
- SomazDocs/**/*
- "!.gitlab-ci.yml"
- "!.gitignore"
gdrive-upload:
stage: gdrive-upload
image: rclone/rclone:latest
script:
- rclone config show --config $CONFIG
- rclone copy ./SomazDocs "Somaz:SomazDocs" --progress --config $CONFIG
tags:
- build-image
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "push"'
<<: *change_files
- rclone copy 명령어는 로컬의 SomazDocs 폴더를 Google Drive 내의 동일한 이름 폴더에 업로드한다.
- Somaz는 `rclone.conf` 에 정의된 remote 이름이다.
- CONFIG 변수는 GitLab에서 파일 타입으로 등록된 `RCLONE_CONFIG` 를 참조한다.
- rules 블록은 웹 UI 실행 또는 특정 폴더 변경 시에만 동작하도록 제어한다.
- copy 말고 sync 명령어를 사용하면 완전 동기화가 된다. (주의: 파일 삭제도 됨)
마무리
rclone은 다양한 클라우드 스토리지를 지원하며, 특히 Google Drive와의 연동이 강력하고 안정적이다. GitLab CI와 연동하면, 파일 업로드를 자동화하여 협업의 효율성과 기록 관리를 동시에 챙길 수 있다.
특히 Google Workspace의 공유 드라이브를 사용하는 경우, team_drive 옵션을 통해 전체 팀이 파일을 실시간으로 확인할 수 있어 더욱 유용하다.
작업자 입장에서는 업로드를 신경 쓸 필요 없이 커밋만 하면 Drive에 자동 저장되므로, 생산성과 일관성을 모두 확보할 수 있다.
Reference
'IaC > CI CD Tool' 카테고리의 다른 글
| GitLab 18.0 업그레이드 시 git_data_dirs 설정 변경 가이드 (2) | 2025.11.05 |
|---|---|
| Git 레포지토리 GitLab 마이그레이션 가이드 (2) | 2025.08.05 |
| 대형 Git 리포지터리에서 CI/CD 시간을 절반으로 줄이는 법: Git Sparse Checkout 실전 적용기 (4) | 2025.06.09 |
| ArgoCD Slack Notification 설정 방법 (0) | 2025.05.08 |
| ArgoCD SSO 구성 가이드(Gitlab) (0) | 2025.03.31 |