본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

설정

원문 보기 위키 갱신

설정 (Configuration)

이 문서는 .drone.yml 구성 파일에 대한 개요를 제공합니다. 구성 파일은 리포지토리의 루트에 두며, 하나 이상의 지속적 통합(CI) 또는 지속적 전달(CD) 파이프라인을 정의합니다.

출처: Drone CI Docs

본문

파이프라인 구성 예시:

kind: pipeline
type: docker
name: default

steps:
- name: test
  image: golang
  commands:
  - go build
  - go test

객체(Objects)

구성 파일은 하나의 파일에 하나 이상의 객체를 정의하며, 각 객체는 별개의 yaml 문서입니다. 파이프라인은 객체의 한 종류입니다. Signature 객체와 Secret 객체도 정의할 수 있습니다.

Pipeline 구성 예시:

kind: pipeline
type: docker
name: default

steps:
- name: test
  image: golang
  commands:
  - go build
  - go test

Pipeline과 Signature 구성 예시:

---
kind: pipeline
type: docker
name: default

steps:
- name: test
    image: golang
    commands:
    - go build
    - go test

---
kind: signature
hmac: F10E2821BBBEA527EA02200352313BC059445190

각 객체는 kind 속성을 반드시 포함해야 합니다. kind 속성은 선언되는 객체의 종류를 식별하고 객체를 서로 구별하는 데 도움을 줍니다.

파이프라인(Pipelines)

Pipeline 객체는 지속적 통합과 지속적 전달 파이프라인을 정의합니다. type 속성은 파이프라인 실행 시 사용할 런타임을 정의합니다. Drone은 다양한 런타임을 지원합니다.

각 파이프라인 스텝을 격리된 Docker 컨테이너 안에서 실행하는 Docker 파이프라인 예시:

kind: pipeline
type: docker

파이프라인 스텝을 Kubernetes 파드 안의 컨테이너로 실행하는 Kubernetes 파이프라인 예시:

kind: pipeline
type: kubernetes

파이프라인 스텝을 격리 없이 호스트 머신에서 직접 실행하는 Exec 파이프라인 예시:

kind: pipeline
type: exec

여러 파이프라인

동일한 구성 파일에 여러 Pipeline 객체를 정의하면 파이프라인이 여러 러너에 분산되어 병렬로 실행됩니다. 아래 예시는 두 파이프라인을 병렬로 실행하도록 구성합니다. 전체 빌드 상태는 두 파이프라인이 모두 성공적으로 완료되는지로 결정됩니다.

파이프라인 간에는 상태를 공유하지 않는다는 점에 유의하세요. 두 파이프라인이 동일한 기반 파일 시스템이나 생성된 파일에 접근하는 것은 불가능합니다.

여러 파이프라인을 실행할 때 형제(sibling) 파이프라인 중 하나라도 실패하면 이후 빌드 파이프라인들은 중단됩니다. 이는 형제 파이프라인의 스케줄링에 따라 다르게 동작할 수 있으며, 비결정적 동작을 유발합니다.

kind: pipeline
type: docker
name: backend

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

---
kind: pipeline
type: docker
name: frontend

steps:

- name: build
  image: node
  commands:
  - npm install
  - npm test

여러 플랫폼

여러 파이프라인의 대표적인 사용 사례는 서로 다른 플랫폼용 파이프라인을 정의하고 실행하는 것입니다. 예를 들어 x86에서 하나의 파이프라인을, arm에서 다른 파이프라인을 실행할 수 있습니다.

kind: pipeline
type: docker
name: amd64

platform:
  arch: amd64

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

---
kind: pipeline
type: docker
name: arm

platform:
  arch: arm64

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

그래프 실행

Drone은 파이프라인을 방향성 비순환 그래프(DAG)로 기술하는 것도 지원합니다. 아래 예시에서는 처음 두 파이프라인을 병렬로 실행하도록 fan-out하고, 완료되면 마지막 파이프라인을 실행하도록 fan-in합니다.

kind: pipeline
type: docker
name: backend

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

---
kind: pipeline
type: docker
name: frontend

steps:
- name: build
  image: node
  commands:
  - npm install
  - npm test

---
kind: pipeline
name: after

steps:
- name: notify
  image: plugins/slack
  settings:
    room: general
    webhook: https://...

depends_on:
- backend
- frontend

스크립팅

Drone은 yaml보다 강력한 대안이 필요할 때를 위한 사용자 지정 언어 확장을 지원합니다. 자세한 내용은 Starlark와 Jsonnet 문서를 참고하세요. 자신만의 언어 확장을 만들 수도 있습니다.

더 알아보기 (Learn more)