Travis CI Tutorial

This is a very short guide to using Travis CI with your cloud platform hosted code repository. If you’re new to continuous integration or would like some more information on what Travis CI does, start with Core Concepts for Beginners instead.

Prerequisites #

To start using Travis CI, make sure you have:

To get started with Travis CI using GitHub #

  1. Go to Travis-ci.com and Sign up with GitHub.

  2. Accept the Authorization of Travis CI. You’ll be redirected to GitHub.

  3. Click on your profile picture in the top right of your Travis Dashboard, click Settings and then the green Activate button, and select the repositories you want to use with Travis CI.

Or you click the Activate all repositories using GitHub Apps button on the getting started page to just activate all your repos

  1. Add a .travis.yml file to your repository to tell Travis CI what to do.

    The following example specifies a Ruby project that should be built with Ruby 2.2 and the latest versions of JRuby.

    language: ruby
    rvm:
     - 2.2
     - jruby
    

    The defaults for Ruby projects are bundle install to install dependencies, and rake to build the project.

  2. Add the .travis.yml file to git, commit and push to trigger a Travis CI build:

    Travis only runs builds on the commits you push after you’ve added a .travis.yml file.

  3. Check the build status page to see if your build passes or fails according to the return status of the build command by visiting Travis CI and selecting your repository.

To get started with Travis CI using Bitbucket #

This section documents the new Bitbucket option that is currently in beta.

  1. Go to Travis-ci.com and Sign up with Bitbucket.

  2. Accept the Authorization of Travis CI. You’ll be redirected to Bitbucket.

  3. Click on your profile picture in the top right of your Travis Dashboard, click Settings, and toggle the repositories you want to use with Travis CI.

  4. Add a .travis.yml file to your repository to tell Travis CI what to do.

    The following example specifies a Ruby project that should be built with Ruby 2.2 and the latest versions of JRuby.

    language: ruby
    rvm:
     - 2.2
     - jruby
    

    The defaults for Ruby projects are bundle install to install dependencies, and rake to build the project.

  5. Add the .travis.yml file to git, commit and push to trigger a Travis CI build:

    Travis only runs builds on the commits you push after you’ve added a .travis.yml file.

  6. Check the build status page to see if your build passes or fails according to the return status of the build command by visiting Travis CI and selecting your repository.

To get started with Travis CI using GitLab #

This section documents the new GitLab option that is currently in beta.

  1. Go to Travis-ci.com and Sign up with GitLab.

  2. Accept the Authorization of Travis CI. You’ll be redirected to GitLab.

  3. Click on your profile picture in the top right of your Travis Dashboard, click Settings, and toggle the repositories you want to use with Travis CI.

  4. Add a .travis.yml file to your repository to tell Travis CI what to do.

    The following example specifies a Ruby project that should be built with Ruby 2.2 and the latest versions of JRuby.

    language: ruby
    rvm:
     - 2.2
     - jruby
    

    The defaults for Ruby projects are bundle install to install dependencies, and rake to build the project.

  5. Add the .travis.yml file to git, commit and push to trigger a Travis CI build:

    Travis only runs builds on the commits you push after you’ve added a .travis.yml file.

  6. Check the build status page to see if your build passes or fails according to the return status of the build command by visiting Travis CI and selecting your repository.

To get started with Travis CI using Assembla #

This section documents the new Assembla option that is currently in beta.

  1. Go to Travis-ci.com and Sign up with Assembla.

  2. Accept the Authorization of Travis CI. You’ll be redirected to Assembla.

  3. Click on your profile picture in the top right of your Travis Dashboard, click Settings, and toggle the repositories you want to use with Travis CI.

  4. Add a .travis.yml file to your repository to tell Travis CI what to do.

    The following example specifies a Ruby project that should be built with Ruby 2.2 and the latest versions of JRuby.

    language: ruby
    rvm:
     - 2.2
     - jruby
    

    The defaults for Ruby projects are bundle install to install dependencies, and rake to build the project.

  5. Add the .travis.yml file to git, commit and push to trigger a Travis CI build:

    Travis only runs builds on the commits you push after you’ve added a .travis.yml file.

  6. Check the build status page to see if your build passes or fails according to the return status of the build command by visiting Travis CI and selecting your repository.

Switching accounts #

You can easily switch between your cloud platform provider accounts:

  1. Click on your account icon in the top right corner on Travis-ci.com.

  2. Select the desired account and have fun using Travis CI.

Selecting a different programming language #

Use one of these common languages:

language: ruby
language: java
language: node_js
language: python
language: php
language: go

If you have tests that need to run on macOS or your project uses Swift or Objective-C, use our macOS environment:

os: osx

You do not necessarily need to use macOS if you develop on a Mac. macOS is required only if you need Swift, Objective-C, or other macOS-specific software.

Travis CI supports many programming languages.

More than running tests #

Travis CI isn’t just for running tests, there are many other things you can do with your code:

Further Reading #

Read more about