Templates can be used by setting the kind to ’template’, the name of the base template to load, and a set of freeform template inputs in their drone.yml file:
kind: template
load: plugin.yaml
data:
name: name
image: image
commands: commands
Example base template:
kind: pipeline
type: docker
name: default
steps:
- name: {{ .input.name }}
image: {{ .input.image }}
commands:
- {{ .input.commands }}
Example base template with iteration:
kind: pipeline
type: docker
name: default
steps:
- name: {{ .input.name }}
image: {{ .input.image }}
commands:
{{ range .input.commands }}
- {{ . }}
{{ end }}
.drone.yml with iteration:
kind: template
load: plugin.yaml
data:
name: name
image: image
commands:
- whoami
- date
Predefined variable list can be found at: https://docs.drone.io/template/variables
Create organization templates using the command line tools:
$ drone template add [namespace] [name] [data]
$ drone template add octocat template_name @path_to_file