Quick reference

Travis CI Cheatsheet

Quick reference guide for Travis CI .travis.yml configuration, covering build lifecycles, matrix builds, environments, and deployment.

· Published

Quick reference for .travis.yml configuration files on Travis CI.

Language Environments

Node.js Configuration

language: node_js
node_js:
  - '18'
  - '20'

script:
  - npm test

Ruby Configuration

language: ruby
rvm:
  - 3.1
  - 3.2

script:
  - bundle exec rake test

Build Lifecycle Phases

The Travis CI build lifecycle executes in the following sequence:

  1. before_install
  2. install
  3. before_script
  4. script
  5. after_success or after_failure
  6. after_script
  7. before_deploy (optional)
  8. deploy (optional)
  9. after_deploy (optional)

Custom Script Steps

before_script:
  - make pretest
script:
  - make test
after_script:
  - make clean

Branch Filtering

branches:
  only:
    - main
    - /^release-.*$/
  except:
    - legacy

Matrix and Environment Variables

env:
  - DB=postgresql
  - DB=mysql

System Dependencies with Apt

addons:
  apt:
    packages:
      - libcurl4-openssl-dev

References

Related topics