Skip to content

Instantly share code, notes, and snippets.

@ajdruff
Forked from purp/README.md
Last active February 7, 2020 02:36
Show Gist options
  • Save ajdruff/dc78cc17cb48afdf85dc11cbc041564b to your computer and use it in GitHub Desktop.
Save ajdruff/dc78cc17cb48afdf85dc11cbc041564b 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 autolibs enable
    rvm install 2.6.3
    rvm use 2.6.3
    gem install travis
    travis version # generates ~/.travis
    cd builds
    git clone https://github.com/travis-ci/travis-support.git
    git clone https://github.com/travis-ci/travis-rollout.git
    git clone https://github.com/travis-ci/travis-build.git
    git clone https://github.com/travis-ci/github_apps.git
    cd travis-support
    gem build travis-support.gemspec
    gem install travis-support-0.0.1.gem
    cd ../travis-rollout
    gem build travis-rollout.gemspec
    gem install travis-rollout-0.0.1.gem
    cd ../github_apps
    gem build travis-github_apps.gemspec
    gem install travis-github_apps-0.2.0.gem
    cd ../travis-build     
    ln -s `pwd` ~/.travis/travis-build
    bundle install
    bundle add travis

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment