Skip to content

Instantly share code, notes, and snippets.

@purp
Last active October 21, 2024 15:21
Show Gist options
  • Save purp/0df77b579031127f10f31ebd202e8fd4 to your computer and use it in GitHub Desktop.
Save purp/0df77b579031127f10f31ebd202e8fd4 to your computer and use it in GitHub Desktop.
Debug Travis CI config locally using Docker

Debugging Travis CI locally using Docker

This assumes you've got docker-machine installed, running, and can do docker run

1. Get a debug instance running

    docker run --name travis-debug -dit quay.io/travisci/travis-ruby /sbin/init
    docker exec -it travis-debug bash -l

2. As root: Install any packages you need via apt-get

3. su - travis

4. Install travis-build

    rvm install 2.2.5
    rvm use 2.2.5
    gem install travis
    travis version # generates ~/.travis
    cd builds
    git clone https://github.com/travis-ci/travis-build.git
    cd travis-build
    ln -s `pwd` ~/.travis/travis-build
    bundle install

5. Install your code and generate the ci.sh script

    github_user_name=YOUR_GITHUB_USER_NAME
    github_repo=YOUR_GITHUB_REPO
    cd ~/builds
    mkdir $github_user_name
    cd $github_user_name
    git clone https://github.com/${github_user_name}/${github_repo}.git
    cd $github_repo
    # change to the branch or commit you want to investigate
    travis compile > ~/builds/ci.sh
    cd ~/builds
    # You most likely will need to edit ci.sh as it ignores matrix and env
    bash ci.sh

Sources

  1. Travis CI Docs: Running a container-based Docker Image
  2. StackOverflow: How to reproduce a Travis CI build environment for debugging
@myosher1
Copy link

myosher1 commented Sep 11, 2019

Hi,
I'm trying to follow your instructions but when i do "gem install travis" i get:

travis@ee87ce656105:~$ gem install travis
ERROR: Could not find a valid gem 'travis' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=unknown state: tlsv1 alert protocol version (https://api.rubygems.org/specs.4.8.gz)

maybe there is something I missed...?

Thanks,

@purp
Copy link
Author

purp commented Sep 11, 2019

Hi, @myosher1 … I haven’t revisited this gist for a while, and can’t chase this just now. My first guess would be around version of Ruby. Maybe try with 2.6.4 or anything 2.6.x?

@yijiangh
Copy link

yijiangh commented Mar 2, 2020

gem install travis

@myosher1 Try the following:

$ gem sources --remove https://rubygems.org/
$ gem sources -a http://rubygems.org/

Found these working like a charm: source here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment