Drone CI 中文文档

Yaml

模板可以通过名称引用的方式,引用类型为 template 流水线基础模板进行。在 drone.yml 文件中,可以使用一组自由(不限制)格式的模板输入来向模板中传入数据。

1
2
3
4
5
6
kind: template
load: plugin.yaml
data:
  name: name
  image: image
  commands: commands

以下是基础模板的示例:

1
2
3
4
5
6
7
8
kind: pipeline
type: docker
name: default
steps:
   - name: {{ .input.name }}
     image: {{ .input.image }}
     commands:
        - {{ .input.commands }}

具有迭代功能的基础模板示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
kind: pipeline
type: docker
name: default
steps:
    - name: {{ .input.name }}
     image: {{ .input.image }}
     commands:
     {{ range .input.commands }}
     - {{ . }}
     {{ end }}

具有迭代功能的 .drone.yml 示例:

1
2
3
4
5
6
7
8
kind: template
load: plugin.yaml
data:
  name: name
  image: image
  commands:
  - whoami
  - date

预定义变量列表可在网址 https://docs.drone.io/template/variables 中查阅。

以下是使用命令行工具创建组织模板的示例:

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