Table of Contents

Drone CLI manage templates

Installation

Download from oofficail website.

Get the token setup in the account setting page.

Template

Templates are used to standardize the pipeline and avoid redundant implementations of similar services and provide better maintainability.

Save template to file

drone template info --name test.yaml --namespace <org name or account name> --format "{{ .Data }}" > build.docker.yaml

Remove template

drone template rm --namespace <org name or account name> --name test.yaml

Add template

 drone template add --namespace <org name or account name> --name build-docker.yaml --data "@./build-docker.yaml"

Update template

 drone template update --namespace <org name or account name> --name build-docker.yaml --data "@./build-docker.yaml"
Tip

@./build-docker.yaml means load load-docer.yaml from current directory.

Use the template

When applying a pipeline to a project, only need to apply the wanted file name.

Example .drone.yml:

kind: template
load: build-docker.yaml # use the template setup previously
data:
  # these data are variables needed by the template 
  repo: example.com/hello
  tags: 
    - latest
    - dev

Troubleshooting

Build Task is never run on a new project

  • Delete .drone.yml from git then commit it again.