There are three environment variables that can be used to configure this feature.
GITHUB_TOKEN. This is required, and should be encrypted in the
.travis.yml, or set securely in the repository settings. This is used as the authentication method for the Travis CI API.
TRAVIS_POLLING_INTERVAL. How often, in seconds, we should check the API to see if the rest of the jobs have completed. Defaults to 5.
TRAVIS_API_URL. The base URL to the Travis API for this build. This defaults to
https://api.travis-ci.org. A common override will be to the commercial version, at
Configure which job to wait on by adding
[travis:after] section to the
travis key looks for values that would be keys
in various items in the
env key looks for values that would be keys
in items in the
[travis:after] travis = python: 3.5 env = DJANGO: 1.8
tox in your test command like this:
For example, consider this mocked up
that corresponds to using the above
sudo: false language: python python: - "2.6" - "3.5" env: global: - GITHUB_TOKEN='spamandeggs' # Make sure this is encrypted! matrix: - DJANGO="1.7" - DJANGO="1.8" install: pip install tox-travis script: tox --travis-after deploy: provider: pypi user: spam password: eggs # Make sure to encrypt passwords! on: tags: true python: 3.5 condition: $DJANGO = "1.8" distributions: sdist bdist_wheel
This example deploys when the build is from a tag
and the build is on Python 3.5
and the build is using DJANGO=”1.8”.
tox --travis-after and Tox’s
make sure that the deploy only happens after all tests pass.
If any configuration item does not match, or if no configuration is given, this will run exactly as it would normally. However, if the configuration matches the current job, then it will wait for all the other jobs to complete before it will be willing to return a success return code.
If the tests fail, then it will not bother waiting, but will rather return immediately. If it determines that another required job has failed, it will return an error indicating that jobs failed.
You can use this together with a deployment configuration to ensure that this job is the very last one to complete, and will only be successful if all others are successful, so that you can be more confident that you are shipping a working release.
The accepted configuration keys
[travis:after] section are:
toxenv. Match with the running toxenvs, based on the
TOXENVenvironment variable, which is set automatically by Tox-Travis. Expansion is allowed, and if set all environments listed must be present in the
travis. Match with known Travis factors, as is done in the
[travis]section. For instance, specifying that we should wait when python is version 2.7 would look like
travis = python: 2.7.
env. Match with environment variable factors, as might be specified in the
[travis:env]section. For instance, if we want to match that
1.9, then it would look like
env = DJANGO: 1.9. The value must match exactly to succeed.