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: digitalocean
3 name: default
4
5 server:
6 host: 1.2.3.4
7 user: root
8 password:
9 from_secret: password
10
11 steps:
12 - name: build
13 commands:
14 - go build
15 - go test
16
17 trigger:
18 branch:
19 - master
You can use wildcard matching in your triggers. Note that triggers use glob pattern matching, not regular expressions.
17 trigger:
18 ref:
19 - refs/heads/master
20 - refs/heads/**
21 - refs/pull/*/head
You can also combine multiple triggers. Note that all triggers must evaluate to true when combining multiple triggers.
17 trigger:
18 branch:
19 - master
20 event:
21 - 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.
17 trigger:
18 branch:
19 - master
20 - feature/*
Example include syntax:
17 trigger:
18 branch:
19 include:
20 - master
21 - feature/*
Example exclude syntax:
17 trigger:
18 branch:
19 exclude:
20 - master
21 - feature/*
By Event
The event trigger limits step execution based on the drone event type. This can be helpful when you want to limit steps based on push, pull request, tag and more.
17 trigger:
18 event:
19 - push
20 - pull_request
21 - tag
22 - promote
23 - rollback
Example include syntax:
17 trigger:
18 event:
19 include:
20 - push
21 - pull_request
Example exclude syntax:
17 trigger:
18 event:
19 exclude:
20 - 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.
17 trigger:
18 ref:
19 - refs/heads/feature-*
20 - refs/tags/*
Example include syntax:
17 trigger:
18 ref:
19 include:
20 - refs/heads/feature-*
21 - refs/pull/**
22 - refs/tags/**
Example exclude syntax:
17 trigger:
18 ref:
19 exclude:
20 - refs/heads/feature-*
21 - refs/pull/**
21 - 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.
17 trigger:
18 repo:
19 - octocat/hello-world
Example include syntax:
17 trigger:
18 repo:
19 include:
20 - octocat/hello-world
21 - spacebhost/hello-world
Example exclude syntax:
17 trigger:
18 repo:
19 exclude:
20 - octocat/hello-world
21 - spacebhost/hello-world
Example using wildcard matching:
17 trigger:
18 repo:
19 include:
20 - octocat/*
By Instance
The instance trigger limits step execution based on the Drone instance hostname. This can be useful if you have multiple Drone instances configured for a single repository, sharing the same yaml file, and want to limit steps by instance.
17 trigger:
18 instance:
19 - drone.instance1.com
20 - drone.instance2.com
Example include syntax:
17 trigger:
18 instance:
19 include:
20 - drone.instance1.com
21 - drone.instance2.com
Example exclude syntax:
17 trigger:
18 instance:
19 exclude:
20 - drone.instance1.com
21 - drone.instance2.com
Example using wildcard matching:
17 trigger:
18 instance:
19 include:
20 - *.company.com
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.
17 trigger:
18 status:
19 - failure
Execute a step on failure:
17 trigger:
18 status:
19 - failure
Execute a step on success or failure:
17 trigger:
18 status:
19 - success
20 - failure
The following configuration is redundant. The default behavior is for pipeline steps to only execute when the pipeline is in a passing state.
17 trigger:
18 status:
19 - success
By Target
The target trigger limits step execution based on the target deployment environment. This only applies to promotion and rollback events.
17 trigger:
18 target:
19 - production
Example include syntax:
17 trigger:
18 target:
19 include:
20 - staging
21 - production
Example exclude syntax:
17 trigger:
18 target:
19 exclude:
20 - production