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.
travis_internal_rubyfunction 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