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 kind: pipeline
2 type: docker
3 name: default
4
5 steps:
6 - name: build
7 image: golang
8 commands:
9 - go build
10 - go test
11
12 trigger:
13 branch:
14 - master
You can use wildcard matching in your triggers. Note that triggers use glob pattern matching, not regular expressions.
12 trigger:
13 ref:
14 - refs/heads/master
15 - refs/heads/**
16 - refs/pull/*/head
You can also combine multiple triggers. Note that all triggers must evaluate to true when combining multiple triggers.
12 trigger:
13 branch:
14 - master
15 event:
16 - 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.
12 trigger:
13 branch:
14 - master
15 - feature/*
Example include syntax:
12 trigger:
13 branch:
14 include:
15 - master
16 - feature/*
Example exclude syntax:
12 trigger:
13 branch:
14 exclude:
15 - master
16 - 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.
12 trigger:
13 event:
14 - cron
15 - custom
16 - push
17 - pull_request
18 - tag
19 - promote
20 - rollback
Example include syntax:
12 trigger:
13 event:
14 include:
15 - push
16 - pull_request
Example exclude syntax:
12 trigger:
13 event:
14 exclude:
15 - 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 trigger:
13 ref:
14 - refs/heads/feature-*
15 - refs/tags/*
Example include syntax:
12 trigger:
13 ref:
14 include:
15 - refs/heads/feature-*
16 - refs/pull/**
17 - refs/tags/**
Example exclude syntax:
12 trigger:
13 ref:
14 exclude:
15 - refs/heads/feature-*
16 - refs/pull/**
17 - 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 trigger:
13 repo:
14 - octocat/hello-world
Example include syntax:
12 trigger:
13 repo:
14 include:
15 - octocat/hello-world
16 - spacebhost/hello-world
Example exclude syntax:
12 trigger:
13 repo:
14 exclude:
15 - octocat/hello-world
16 - spacebhost/hello-world
Example using wildcard matching:
12 trigger:
13 repo:
14 include:
15 - 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 trigger:
13 status:
14 - failure
Execute a step on failure:
12 trigger:
13 status:
14 - failure
Execute a step on success or failure:
12 trigger:
13 status:
14 - success
15 - failure
The following configuration is redundant. The default behavior is a pipeline only executes when the overall build is in a passing state.
12 trigger:
13 status:
14 - success
By Target
The target trigger limits step execution based on the target deployment environment. This only applies to promotion and rollback events.
12 trigger:
13 target:
14 - production
Example include syntax:
12 trigger:
13 target:
14 include:15 - staging
15 - production
Example exclude syntax:
12 trigger:
13 target:
14 exclude:
15 - 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 trigger:
13 event:
14 - cron
15 cron:
16 - nightly
Example include syntax:
12 trigger:
13 event:
14 - cron
15 target:
16 include:
17 - weekly
18 - nightly
Example exclude syntax:
12 trigger:
13 event:
14 - cron
15 target:
16 exclude:
17 - nightly