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

Yaml 템플릿

원문 보기 위키 갱신

Yaml 템플릿 (Yaml Templates)

조직 단위 Yaml 템플릿을 파이프라인에서 사용하는 방법을 설명하는 문서예요. drone.yml에서 템플릿을 로드하고 입력값을 전달할 수 있어요.

출처: Drone CI Docs

본문

템플릿은 drone.yml 파일에서 kind를 'template'으로 설정하고, 로드할 기본 템플릿의 이름과 자유 형식의 템플릿 입력값들(templates inputs)을 지정해 사용할 수 있어요:

kind: template
load: plugin.yaml
data:
  name: name
  image: image
  commands: commands

기본 템플릿 예시:

kind: pipeline
type: docker
name: default
steps:
   - name: {{ .input.name }}
     image: {{ .input.image }}
     commands:
        - {{ .input.commands }}

반복(iteration)을 사용한 기본 템플릿 예시:

kind: pipeline
type: docker
name: default
steps:
    - name: {{ .input.name }}
     image: {{ .input.image }}
     commands:
     {{ range .input.commands }}
     - {{ . }}
     {{ end }}

반복을 사용하는 .drone.yml:

kind: template
load: plugin.yaml
data:
  name: name
  image: image
  commands:
  - whoami
  - date

미리 정의된 변수 목록은 https://docs.drone.io/template/variables 에서 확인할 수 있어요.

명령줄 도구로 조직 템플릿을 만드세요:

$ drone template add [namespace] [name] [data]
$ drone template add octocat template_name @path_to_file

더 알아보기 (Learn more)