클로닝
클로닝 (Cloning)
Drone은 파이프라인 스텝을 실행하기 전에 저장소를 자동으로 클론해요. 별도 설정이 필요 없습니다. 하지만 어떤 경우에는 기본 클론 동작을 커스터마이즈하거나, 재정의하거나, 비활성화해야 할 수도 있어요.
출처: Drone CI Docs
본문
--depth 플래그
기본 클론 설정은 --depth 플래그를 사용하지 않아요. 클론 깊이를 강제하려면 clone 블록을 선언하고 depth 속성을 추가하면 됩니다:
kind: pipeline
type: kubernetes
name: default
clone:
depth: 50
steps:
- name: build
image: golang
commands:
- go build
- go test
--tags 플래그
기본 클론 설정은 --tags 플래그를 사용하지 않아요. 태그를 가져오고 싶다면 파이프라인의 스텝으로 처리해야 합니다. 예를 들면:
kind: pipeline
type: kubernetes
name: default
steps:
- name: fetch
image: alpine/git
commands:
- git fetch --tags
- name: build
image: golang
commands:
- go build
- go test
--recursive 플래그
기본 클론 동작은 --recursive 플래그를 사용하지 않고 서브모듈도 가져오지 않아요. 서브모듈을 가져오고 싶다면 파이프라인의 스텝으로 처리해야 합니다. 예를 들면:
kind: pipeline
type: kubernetes
name: default
steps:
- name: submodules
image: alpine/git
commands:
- git submodule init
- git submodule update --recursive --remote
- name: build
image: golang
commands:
- go build
- go test
커스텀 로직
필요하다면 기본 클론 동작을 비활성화하고 커스텀 클론 로직을 구현할 수 있어요. 다음 예제는 커스텀 클론 명령을 파이프라인 스텝으로 구현합니다:
kind: pipeline
type: kubernetes
name: default
clone:
disable: true
steps:
- name: clone
image: alpine/git
commands:
- git clone https://github.com/octocat/hello-world.git .
- git checkout $DRONE_COMMIT
- name: build
image: golang
commands:
- go build
- go test