Jsonnet 템플릿
kind: template로 Jsonnet 기반 템플릿 파이프라인을 사용하는 방법을 설명하는 문서예요. 자유 형식의 템플릿 입력값을 넘겨 재사용 가능한 파이프라인을 만들 수 있어요.
출처: Drone CI Docs
본문
템플릿은 drone.yml 파일에서 kind를 ’template’으로 설정하고, 로드할 베이스 템플릿 이름과 자유 형식의 템플릿 입력값 세트를 지정해 사용할 수 있어요:
kind: template
load: plugin.jsonnet
data:
stepName: my_step
image: my_image
commands: my_command
베이스 템플릿 예시:
local stepName = std.extVar("input.stepName");
local image = std.extVar("input.image");
local commands = std.extVar("input.commands");
{
"kind": "pipeline",
"type": "docker",
"name": "default",
"steps": [
{
"name": stepName,
"image": image,
"commands": [
commands
]
}
]
}
미리 정의된 변수 목록은 https://docs.drone.io/template/variables에서 확인할 수 있어요.
커맨드 라인 도구로 조직 템플릿을 만들 수 있어요:
$ drone template add [namespace] [name] [data]
$ drone template add octocat template_name @path_to_file
더 알아보기 (Learn more)
- Template Variables — 미리 정의된 변수 목록