This page documents deployments using the next major version dpl v2 which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.
Set your build to deploy only in specific circumstances by using the
option for any deployment provider.
deploy: provider: <provider> # ⋮ on: branch: release condition: $MY_ENV = value
If all conditions specified in the
on section are met, your build will deploy.
The following conditions are available:
To deploy only when the build occurs on a particular repository, add
repo in the form
deploy: provider: <provider> # ⋮ on: repo: travis-ci/dpl
By default, deployments will only happen on the
master branch. You can overwrite this by using the
For example, to deploy on the
production branch only use:
deploy: provider: <provider> # ⋮ on: branch: production
In order to deploy from all branches:
deploy: provider: <provider> # ⋮ on: all_branches: true
You can specify a single Bash
condition that needs to evaluate to
order for the deployment to happen.
This must be a string value that will be wrapped into
if [[ <condition> ]]; then <deploy>; fi.
For example, in order to only deploy if
deploy: provider: s3 # ⋮ on: condition: $CC = gcc
You can specify whether or not to deploy on tag builds using the option
If set to to
true the deployment will only happen on tag builds, if set to
false it will not happen on tag builds.
For example, in order to deploy on tag builds only:
deploy: provider: <provider> # ⋮ on: tags: true
falseor any other string:
This will check if the environment variable
$TRAVIS_TAG is set. Depending on
your workflow, you may set
$TRAVIS_TAG explicitly, even if this is a non-tag
build when it was initiated.
true causes the
branch condition to be ignored, otherwise
$TRAVIS_TAG is ignored, and the
branch condition is considered.
Examples for conditional deployments #
This deploys using a custom script
deploy.sh, only for builds on the branches
deploy: provider: script script: deploy.sh on: all_branches: true condition: $TRAVIS_BRANCH =~ ^(staging|production)$
This deploys using custom scripts
deploy_staging.sh depending on the branch that triggered the job.
deploy: - provider: script script: deploy_production.sh on: branch: production - provider: script script: deploy_staging.sh on: branch: staging
This deploys to S3 only when
$CC is set to
deploy: provider: s3 access_key_id: <encrypted access_key_id> secret_access_key: <encrypted secret_access_key> bucket: <bucket> on: condition: $CC = gcc