How to Run TravisCI locally on Docker

Ibrahim Ulukaya
Apr 19, 2017 · 2 min read

Have a private Github repo that you don’t want Travis to access? Scratching your head on a build error but can’t see logs? Build it locally! (Interested in TravisCI configuration?)

Image for post
  1. Install Docker
  2. Install Travis on Docker
# choose the image according to the language chosen in .travis.yml
$ docker run -it -u travis quay.io/travisci/travis-jvm /bin/bash
# now that you are in the docker image, switch to the travis user
sudo — travis
# Install a recent ruby (default is 1.9.3)
rvm install 2.3.0
rvm use 2.3.0
# Install travis-build to generate a .sh out of .travis.yml
cd builds \
git clone https://github.com/travis-ci/travis-build.git \
cd travis-build \
gem install travis \
travis # to create ~/.travis \
ln -s `pwd` ~/.travis/travis-build \
bundle install
# Create ssh key for Github
ssh-keygen -t rsa -b 4096 -C “YOUR EMAIL REGISTERED IN GITHUB”
# Click enter to use default location for key
# You can choose empty passphrase by clicking enter twice
# Now that we have the key, let’s share with Github
less ~/.ssh/id_rsa.pub
# Copy the contents of the id_rsa.pub

3. Go to your Github SSH key settings
4. Create a new ssh key with title: “docker key”: “PASTE THE KEY CONTENTS HERE”
5. Go back to docker terminal

# Create project dir, assuming your project is `AUTHOR/PROJECT` on GitHub
cd ~/builds \
mkdir AUTHOR \
cd AUTHOR \
git clone git@github.com:AUTHOR/PROJECT.git \
cd PROJECT
# change to the branch or commit you want to investigate
# compile travis script into bash script
travis compile > ci.sh
# Go to bash script and fix the branch name
vi ci.sh
# in Vi type “/branch” to search and add the right branch name
# — branch\=\’\NEW_BRANCH’\
# You most likely will need to edit ci.sh as it ignores ‘matrix’ and ‘env’ keywords
bash ci.sh

Congrats, in few steps you are already running TravisCI locally.

Google Developers

Engineering and technology articles for developers, written…

Ibrahim Ulukaya

Written by

iOS Engineer. Adventurer. @Firebase

Google Developers

Engineering and technology articles for developers, written and curated by Googlers. The views expressed are those of the authors and don't necessarily reflect those of Google.

Ibrahim Ulukaya

Written by

iOS Engineer. Adventurer. @Firebase

Google Developers

Engineering and technology articles for developers, written and curated by Googlers. The views expressed are those of the authors and don't necessarily reflect those of Google.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store