How to reproduce a travis-ci build environment for debugging

后端 未结 4 1983
庸人自扰
庸人自扰 2020-12-07 13:29

I am seeing a build failure on travis-ci, which I cannot reproduce on my local machine. Are there instructions somewhere for setting up a VM that is identical to the travis

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 13:56

    Eregon's answer failed for me at travis compile, there error looks like:

    /home/travis/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- travis/support (LoadError)
    

    I got it working with the following adjustments: (Adjustments marked with # CHANGED. I'm using the node environment)

    # change the image according to the language chosen in .travis.yml
    # Find images at https://quay.io/organization/travisci
    docker run -it quay.io/travisci/travis-node-js /bin/bash
    
    # now that you are in the docker image, switch to the travis user
    su travis
    
    # Install a recent ruby (default is 1.9.3) to make bundle install work
    rvm install 2.3.0 
    rvm use 2.3.0
    
    # Install travis-build to generate a .sh out of .travis.yml
    sudo mkdir builds         # CHANGED
    cd builds
    sudo 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
    bundler add travis        # CHANGED
    sudo mkdir bin            # CHANGED
    sudo chmod a+w bin/       # CHANGED
    bundler binstubs travis   # CHANGED
    
    # Create project dir, assuming your project is `me/project` on GitHub
    cd ~/builds
    mkdir me
    cd me
    git clone https://github.com/me/project.git
    cd project
    # change to the branch or commit you want to investigate
    ~/.travis/travis-build/bin/travis compile > ci.sh # CHANGED
    # You most likely will need to edit ci.sh as it ignores matrix and env
    # In particular I needed to edit --branch=’’ to the branch name
    bash ci.sh
    

提交回复
热议问题