Travis Build exposes an API that Travis Workers and Job Board use to generate a bash script which is then copied to the job execution environment and executed, with the resulting output streamed back to Travis.
This code base has gone through several iterations of development, and was originally extracted from the legacy Travis Worker, before taking its current form.
Run
bundle exec rake specYou can set travis-build up as a plugin for the command line client:
ln -s PATH_TO_TRAVIS_BUILD ~/.travis/travis-build
gem install bundler
bundle install --gemfile ~/.travis/travis-build/Gemfile
bundler binstubs travisYou will now be able to run travis compile, which produces the bash script
that runs the specified job, except that the secure environment variables are
not defined, and that the build matrix expansion is not considered, e.g:
~/.travis/travis-build/bin/travis compileThe resulting script contains commands that make changes to the system on which
it is executed (e.g., edit /etc/resolv.conf, install software). Some require
sudo privileges and they are not easily undone.
It is highly recommended that you run this in a container or other virtualized environment.
The command can be invoked in 3 ways:
Without an argument, it produces the bash script for the local .travis.yml
without considering env and matrix values (travis-build is unable to
expand these keys correctly).
~/.travis/travis-build/bin/travis compileWith a single integer, it produces the script for the given build (or the first job of that build matrix).
~/.travis/travis-build/bin/travis compile 8With an argument of the form M.N, it produces the bash script for the job
M.N.
~/.travis/travis-build/bin/travis compile 351.2The generated script can be used in a container or virtualized environment that closely mimics Travis CI's build environment to aid you in debugging the build failures. Instructions for running such a container are available in the Travis CI docs.
In addition to the travis CLI plugin you can also run the standalone CLI script:
bundle exec script/compile < payload.json > build.shIf you want to run travis-build locally on your machine (e.g. to interact with worker), you can also run it as a docker container with docker-compose:
First, build the image:
docker-compose build webSecond, run the image:
docker-compose run webYou may wish to run with a different setup for local development.
The following shows running travis-build in the development
environment, forwarding the Docker image's port 4000 to the host's
port 4000:
docker-compose run -e RACK_ENV=development -p 4000:4000 webSee docker-compose documentation
for more information.
See LICENSE file.
Copyright (c) 2011-2016 Travis CI development team.