Skip to content

Configuring TravisCI

Raymie Stata edited this page Jan 29, 2018 · 7 revisions

TravisCI is a widely-used, hosted build, test, and deployment automation server that is closely integrated into GitHub. It is one of many such services (as is CircleCI and CodeShip).

Your code repository has a file named .travis.yml that contains the build instructions for the Travis service. In the Monday on-boarding session, we deferred configuring Travis for your fork of Limbo. In this lab we will do that configuration.

Here are the steps for this configuration:

  1. Log into Travis using your GitHub account
  2. Give Travis the GitHub permissions needed to pull code to run builds
  3. Enable builds for your fork of Limbo
  4. Setup the environment variables needed to run the build
  5. Trigger an initial build to make sure everything is working

Let's go through each step in detail.

Log into Travis using your GitHub account

Go to the TravisCI Website. Note that, since we're building a public fork of a public repository, we got to travis-ci.ORG, not travis-ci.COM (the latter is for private projects and costs money). Here's what you should see:

In the upper-right corner, click "Sign in with GitHub." If you're already logged into GitHub, you'll be taken directly to the next screenshot below. If you are not logged in, then you'll be taken to GitHub to log in, and then you'll be taken to the next screenshot.

Give Travis the GitHub permissions needed to pull code to run builds

When you log into Travis for the first time, you are taken to the following GitHub page:

The arrow is there to emphasize that this is a GitHub page, not a Travis page. In going to this page, Travis has asked GitHub for privileges to checkout repositories, set Webhooks for event notifications, and for other permissions. GitHub, in turn, is asking your permission to grant those privileges in the page above.

You give that permission by clicking "Authorize travis-ci." As we'll cover in our security discussion, you should not fall into the habit of granting such permissions lightly. Look at these permissions and make sure you understand them. Do a little Web searching on Travis to see if they are a legit company. If you are okay with granting these permissions, go ahead and click the button. If you don't understand or are not okay with granting these permissions, then talk to an instructor.

If you grant the permissions, you are brought back to your Travis home page:

Along the left will be all the public repositories you have in your account (the user in this case has only two).

The next step is to enable builds for your Limbo fork. To do that, you need to go to your profile page, which you can do by clicking your user name (circled in red in the above screen shot).

Enable builds for your fork of Limbo

Your profile page will look something like this:

For each of your repositories, you'll see a "light switch" indicating whether or not builds are enabled for that repository. Find the Travis switch for the repository of your Limbo fork (circled in red above) and click it to enable builds. The screen will then look something like this:

Once builds are enabled, you need to configure the environment for the build. You do this on the Travis settings page for the Limbo repository, which you can get to by clicking the "gear" circled in red.

Setup the environment variables needed to run the build

The Travis settings page for your Limbo repository looks something like this:

The red arrow points to where you need to enter the environment variables for your build. If you followed the instructions in on this page, then the environment variables you need will be stored in a file named .env. As you enter these values, ensure that the "Display value in build log" is set to OFF for all of your credentials (OFF is the default). After you enter those variables, your settings page will look something like this:

You are now ready to trigger a build. To do that, go to the Travis homepage for the Limbo repository, which you can do by clicking the link circled in red at the top of the above screen shot.

Trigger an initial build to make sure everything is working

In the Travis homepage for the Limbo repository, you will see there are no builds:

To test your Travis Limbo configuration, you should launch a build manually. You can do that by selecting the "Trigger build" item from the "More options" menu on the right side of the page (circled in red in the above screen shot). When you do that, the following modal dialog will appear:

You don't need to fill in this dialog, you just need to click the "Trigger custom build" button (circled in red above). Once you do this, you'll be brought to an in-progress build page, which looks something like this:

Over time (10-15 minutes), the build should finish successfully and turn "green." At this point, the build page will look something like this:

If the build fails, make sure that you have created the ECR Repository for your Docker image. Also, make sure that your environment variables were entered correctly.