Script Deployment

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.

Be sure to read the v2 deployment overview.

If your deployment needs more customization than the after_success method allows, use a custom script.

The following example runs scripts/deploy.sh on the develop branch of your repository if the build is successful.

deploy:
  provider: script
  script: bash scripts/deploy.sh
  on:
    branch: develop

If you need to run multiple commands, write a executable wrapper script that runs them all. The argument to script: in the script deployment provider needs to be a single command.

If the script returns a nonzero status, deployment is considered a failure, and the build will be marked as “errored”.

Passing Arguments to the Script #

It is possible to pass arguments to a script deployment.

deploy:
  # deploy develop to the staging environment
  - provider: script
    script: bash scripts/deploy.sh staging
    on:
      branch: develop
  # deploy master to production
  - provider: script
    script: bash scripts/deploy.sh production
    on:
      branch: master

The script has access to all the usual environment variables.

deploy:
  provider: script
  script: bash scripts/deploy.sh production $TRAVIS_TAG
  on:
    tags: true
    all_branches: true

Ruby version #

To ensure that deployments run consistently, we use the version of Ruby that is pre-installed on all of our build images, which may change when images are updated.

  • The travis_internal_ruby function prints the exact pre-installed Ruby version

If you need to run a command that requires a different Ruby version than the pre-installed default, you need to set it explicitly:

deploy:
  provider: script
  script: rvm use $TRAVIS_RUBY_VERSION do script.rb

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #