Skip to content

Instantly share code, notes, and snippets.

@HariSekhon
Created March 22, 2024 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HariSekhon/bd4f8e7f511593534f08cfae2dd2eaf2 to your computer and use it in GitHub Desktop.
Save HariSekhon/bd4f8e7f511593534f08cfae2dd2eaf2 to your computer and use it in GitHub Desktop.
travis.md from HariSekhon/Knowledge-Base repo: https://github.com/HariSekhon/Knowlege-Base

Travis CI

One of the original hosted CI/CD systems.

Reasonable UI, but...

travis-ci.org was free for open source, but has been retired.

travis-ci.com remains as a paid offering.

This has caused Travis CI to go from once leading open source to now legacy CI/CD.

Superceded by newer more free CI/CD systems like GitHub Actions now which is unlimited free for all public projects.

Travis CI Template

Copy to root of GitHub repo and edit:

.travis.yml

Online Config Validator

Paste .travis.yml config in this online validator to see parsing and job matrix:

https://config.travis-ci.com/explore

Desktop Menu Notifications

Travis CI URL for monitoring a Repo

Here is the URL for the above desktop notifiation tools

https://api.travis-ci.org/repos/<owner>/<repo>/cc.xml

Returns empty json {} if it doesn't find the repo

Config I used for CCMenu on Mac for several years to monitor my GitHub repos:

CCMenu.plist

Travis CI CLI

Follow the install doc or paste this to run an automated install script which auto-detects and handles Mac or Linux:

git clone https://github.com/HariSekhon/DevOps-Bash-tools
bash-tools/install/install_travis.sh

OR manually:

gem install travis --no-rdoc --no-ri
travis login
travis token

CLI Usage

Linting:

travis lint  # .travis.yml

Switches of notes:

Switch Description
-q quiet mode
-x exit 1 if lint fails
travis lint -x .travis.yml
travis endpoint --org --set-default
travis login

Set up this token in github:

travis login --github-token

Set up token in .netrc:

travis login --auto
travis monitor -r <repo1> -r <repo2>
Switch Description
-n all my repos
-m notify desktop

Left hand pan recent repo statuses:

travis whatsup
travis history

Create .travis.yml template for given lang:

travis init <lang>
travis init java

Restart Travis CI build from within a Git repo checkout:

travis restart

Make sure it is case sensitive otherwise you'll get output:

repository not known to https://api.travis-ci.org/: harisekhon/nagios-plugins

in local checkout's .git/config:

[travis]
    slug = HariSekhon/nagios-plugins

Docker

Travis hosts containers on Quay.io

  • port 22
  • login:
    • user: travis
    • password: travis

Supported for the following languages:

  • android
  • erlang
  • go
  • haskell
  • jvm
  • node-js
  • perl
  • php
  • python
  • ruby

Hangs so don't run in foreground:

docker run -d -p 2222; 22 --name travis-${TRAVIS_LANGUAGE} quay.io/travisci/travis-${TRAVIS_LANGUAGE}
ssh -p 2222 travis@$HOST # pw travis

or

docker exec travis-${TRAVIS_LANGUAGE}
su - travis

Troubleshooting

Launch a debug VM

Username + Password for GitHub:

travis login --org --auto
travis token --org

This should be the last bit of the url, eg.

https://travis-ci.org/HariSekhon/nagios-plugin-kafka/jobs/144678953

means

JOB_ID=144678953
export JOB_ID
export TRAVIS_TOKEN=$(travis token --org | awk '{print $2}')
echo "Travis token is $TRAVIS_TOKEN"
curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token $TRAVIS_TOKEN" "https://api.travis-ci.org/job/$JOB_ID/debug"

travis_debug() in .bash.d/travis_ci.sh

In Web UI log, see lines

Setting up debug tools.
Preparing debug sessions.
Use the following SSH command to access the interactive debugging environment:
ssh <login_token>@ny2.tmate.io

SSH to the given address on the last line.

Debug Automation

From DevOps-Python-tools repo:

  • travis_debug_session.py
    • automates creating a Travis CI interactive debug build session via the Travis API
    • tracks the creation of the debug build, parses the log and drops you in to the unique SSH shell login as soon as it's available
  • travis_last_log.py
    • automates fetching the last running / completed / failed build log from Travis CI via the Travis API
Ported from private Knowledge Base page 2014+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment