Triggers

When you push code to your repository, open a pull request, or create a tag, your source control management system automatically sends a webhook to Drone which in turn triggers pipeline execution. Use the triggers section to limit pipeline execution.

Example limits pipeline execution by branch:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
kind: pipeline
type: vm
name: default

pool:
  use: ubuntu

steps:
- name: build
  image: golang
  commands:
  - go build
  - go test

trigger:
  branch:
  - master

You can use wildcard matching in your triggers. Note that triggers use glob pattern matching, not regular expressions.

12
13
14
15
16
trigger:
  ref:
  - refs/heads/master
  - refs/heads/**
  - refs/pull/*/head

You can also combine multiple triggers. Note that all triggers must evaluate to true when combining multiple triggers.

12
13
14
15
16
trigger:
  branch:
  - master
  event:
  - push

By Branch

The branch trigger limits step execution based on the git branch. Please note that the target branch is evaluated for pull requests; and branch names are not available for tag events.

Note that you cannot use branch triggers with tags. A tag is not associated with the source branch from which it was created.
12
13
14
15
trigger:
  branch:
  - master
  - feature/*

Example include syntax:

12
13
14
15
16
trigger:
  branch:
    include:
    - master
    - feature/*

Example exclude syntax:

12
13
14
15
16
trigger:
  branch:
    exclude:
    - master
    - feature/*

By Event

The event trigger limits pipeline execution based on the drone event type. This can be helpful when you want to limit pipeline execution based on push, pull request, tag and more.

Note that you cannot use branch triggers with tag events. A tag is not associated with the source branch from which it was created.
12
13
14
15
16
17
18
19
20
trigger:
  event:
  - cron
  - custom
  - push
  - pull_request
  - tag
  - promote
  - rollback

Example include syntax:

12
13
14
15
16
trigger:
  event:
    include:
    - push
    - pull_request

Example exclude syntax:

12
13
14
15
trigger:
  event:
    exclude:
    - pull_request

By Reference

The reference trigger limits step execution based on the git reference name. This can be helpful when you want to glob match branch or tag names.

12
13
14
15
trigger:
  ref:
  - refs/heads/feature-*
  - refs/tags/*

Example include syntax:

12
13
14
15
16
17
trigger:
  ref:
    include:
    - refs/heads/feature-*
    - refs/pull/**
    - refs/tags/**

Example exclude syntax:

12
13
14
15
16
17
trigger:
  ref:
    exclude:
    - refs/heads/feature-*
    - refs/pull/**
    - refs/tags/**

By Repository

The repository trigger limits step execution based on repository name. This can be useful when Drone is enabled for a repository and its forks, and you want to limit execution accordingly.

12
13
14
trigger:
  repo:
  - octocat/hello-world

Example include syntax:

12
13
14
15
16
trigger:
  repo:
    include:
    - octocat/hello-world
    - spacebhost/hello-world

Example exclude syntax:

12
13
14
15
16
trigger:
  repo:
    exclude:
    - octocat/hello-world
    - spacebhost/hello-world

Example using wildcard matching:

12
13
14
15
trigger:
  repo:
    include:
    - octocat/*

By Status

The status trigger limits step execution based on the pipeline status. For example, you may want to configure Slack notification only on failure.

12
13
14
trigger:
  status:
  - failure

Execute a step on failure:

12
13
14
trigger:
  status:
  - failure

Execute a step on success or failure:

12
13
14
15
trigger:
  status:
  - success
  - failure

The following configuration is redundant. The default behavior is a pipeline only executes when the overall build is in a passing state.

12
13
14
trigger:
  status:
  - success

By Target

The target trigger limits step execution based on the target deployment environment. This only applies to promotion and rollback events.

12
13
14
trigger:
  target:
  - production

Example include syntax:

12
13
14
15
16
trigger:
  target:
    include:
    - staging
    - production

Example exclude syntax:

12
13
14
15
trigger:
  target:
    exclude:
    - production

By Cron

The cron trigger limits step execution based on the cron name that triggered the pipeline. This only applies to cron events.

12
13
14
15
16
trigger:
  event:
  - cron
  cron:
  - nightly

Example include syntax:

12
13
14
15
16
17
18
trigger:
  event:
  - cron
  target:
    include:
    - weekly
    - nightly

Example exclude syntax:

12
13
14
15
16
17
trigger:
  event:
  - cron
  target:
    exclude:
    - nightly

By Action

The action trigger limits execution based on the action associated with the event that triggered the pipeline.

Action support varies by event and SCM provider.

Execute when a pull request is opened:

12
13
14
15
16
trigger:
  event:
  - pull_request
  action:
  - opened

Execute on all pull request actions except “synchronized”:

12
13
14
15
16
17
trigger:
  event:
  - pull_request
  action:
    exclude:
    - synchronized