(Due credit to Trung Lê‘s article on which all this is based)
We recently moved our project’s CI from a TeamCity server onto Travis CI’s new private CI-as-a-service program. We compared several other hosted CI services and found Travis to be the easiest to use, and with the help of Trung’s article also the easiest to debug.
Travis provides all their build worker images as Vagrant boxes available for download. I’d never worked with Vagrant before, but getting it set up is pretty simple. Follow the guide on Vagrant’s page and download the latest version of Vagrant. I’ve found that the boxes that Travis provide right now don’t work with VirtualBox 4.2, and so I’d recommend installing VirtualBox with 4.1 from their ‘older builds’ page.
Once you’re done installing both, you’ll want to install the worker box. The Ruby box is installable via
vagrant box add travis-ruby http://files.travis-ci.org/boxes/provisioned/travis-ruby.box
This will download and install the VM, which will probably take a few minutes. After that’s complete, initialize the box with
vagrant init travis-ruby
which will create a Vagrantfile for you where you can configure various settings for how Vagrant hosts the VM on your machine. I’ve found it necessary to add
config.ssh.username = "travis"
to get SSH to work properly. After that,
vagrant up
vagrant ssh
will connect you to the box, and verify that things are working properly. If you are prompted for a password upon sshing, it should be travis
.
Now you’ll want to either scp your Github SSH key or create a new one and clone your project down to the box. After you have your project, all that remains is to get Travis running.
I haven’t yet figured out how Travis starts from .travis.yml files, so for now we have just created a shell script in which we specify all our Travis setup tasks, put it as the ‘script’ key in our .travis.yml, and then just run it directly on our local box. You can find more info about doing this on the Travis docs page. Aside from working around the .travis.yml, we haven’t seen any other gotchas in simulating the Travis worker process.
Once you’ve successfully gotten your build to run inside the Vagrant box, you can follow the instructions on Vagrant’s site to repackage your customized Travis worker and share it with the rest of your team.
About the Author