Skip to content

Instantly share code, notes, and snippets.

@francois-blanchard
Last active September 15, 2020 08:55
Show Gist options
  • Save francois-blanchard/1564cd9b4220e29b7fb55595cff54f68 to your computer and use it in GitHub Desktop.
Save francois-blanchard/1564cd9b4220e29b7fb55595cff54f68 to your computer and use it in GitHub Desktop.
How to debug a failed travis.ci build

How to debug a failed travis.ci build

1/ Go to travais build

https://travis-ci.com/gitUser/gitRepo/builds/XXXXXX

build

2/ Connect to travis build with ssh

build

connect to travis server with green ssh command

build

3/ Load and install environement

Open .travis.yml for find command line need to execute

# Lauch redis
$ redis-server

# before_script
$ mysql -e 'create database genesis_test'

# before_install:
sudo apt-get install libhiredis-dev
gem install recommendify -v '0.3.8'

# script
$ RAILS_ENV=test bundle exec rake db:migrate --trace
$ bundle exec rake db:test:prepare
$ RAILS_ENV=test rake sunspot:solr:start
$ bundle exec rspec spec/
@cwiechmann
Copy link

cwiechmann commented Oct 30, 2018

I have obtained my token from the website: https://travis-ci.org/ --> Profile --> Settings and used it with the following request:

curl -s -X POST \
   -H "Content-Type: application/json" \
   -H "Accept: application/json" \
   -H "Travis-API-Version: 3" \
   -H "Authorization: token <my_token_goes_here>" \
   -d "{\"quiet\": true}" \
https://api.travis-ci.org/job/<my_job_id>/debug

This is the response I get:

{
  "@type": "error",
  "error_type": "wrong_credentials",
  "error_message": "access denied"
}

Is there anything else I need to do? Is there any authorization needed to access the API with my token?

When doing a restart instead of debug my token is accepted:

{
    "@type": "pending",
    "job": {
        "@type": "job",
        "@href": "/job/448444292",
        "@representation": "minimal",
        "id": 448444292
    },
    "state_change": "restart",
    "resource_type": "job"
}

Thanks
Chris

@brandondrew
Copy link

Instead of opening up your travis.yml file and copying commands from there, Travis has provided several bash functions that run these commands:

travis_run_before_install
travis_run_install
travis_run_before_script
travis_run_script
travis_run_after_success
travis_run_after_failure
travis_run_after_script

@MasterOdin
Copy link

For public repos, you must first email them [email protected] asking them to turn on debug mode for that repo.

@az-pz
Copy link

az-pz commented Apr 12, 2019

@brandondrew Thanks. That was what I was looking for.

@smac89
Copy link

smac89 commented Jun 17, 2019

@MasterOdin Thanks for clarifying this. I was under the impression that emailing travis was an optional method to enable debug build and the other method was to use the API.

@bit2shift
Copy link

@smac89 the easier route is (if you're able) to temporarily make the repository private and then go to Travis CI -> Settings -> Sync account (need to smash that button a couple of times to register your intent).
The Debug Build/Job button should then be available.

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