Conditions

Drone support defining condition pipeline steps in the when block. If all conditions in the when block evaluate to true the step is executed, otherwise it is skipped.

Example conditional execution by branch:

pipeline:
  slack:
    image: plugins/slack
    channel: dev
+   when:
+     branch: master

Branches

Execute a step if the branch is master or develop:

when:
  branch: [master, develop]

Execute a step if the branch is starts with prefix/*:

when:
  branch: prefix/*

Execute a step using custom include and exclude logic:

when:
  branch:
    include: [ master, release/* ]
    exclude: [ release/1.0.0, release/1.1.* ]

Events

Execute a step if the build event is a tag:

when:
  event: tag

Execute a step if the build event is a tag created from the specified branch:

when:
  event: tag
+ branch: master

Execute a step for all non-pull request events:

when:
  event: [push, tag, deployment]

Execute a step for all build events:

when:
  event: [push, pull_request, tag, deployment]

Status

Execute a step when the build status changes:

when:
  status: changed

Execute a step when the build is passing or failing:

when:
  status:  [ failure, success ]

Platform

Execute a step for a specific platform:

when:
  platform: linux/amd64

Execute a step for a specific platform using wildcards:

when:
  platform:  [ linux/*, windows/amd64 ]

Environment

Execute a step for deployment events matching the target deployment environment:

when:
  environment: production
  event: deployment

Matrix

Execute a step for a single matrix permutation:

when:
  matrix:
    GO_VERSION: 1.5
    REDIS_VERSION: 2.8

Questions?

We are always happy to help with questions you might have. Search our documentation or check out answers to common questions. You can also post questions or comments to our community forum.