📢 Attention Salesforce Certified Trailblazers! Maintain your credentials and link your Trailhead and Webassessor accounts by April 19th. Learn more.
close

Get Set Up with GitHub and Travis Continuous Integration

Lightning bolt icon used to indicate that the content is for Lightning Experience

Attention, Trailblazer!

Salesforce has two different desktop user interfaces: Lightning Experience and Salesforce Classic. This module is designed for Lightning Experience.

You can learn about switching between interfaces, enabling Lightning Experience, and more in the Lightning Experience Basics module here on Trailhead.

Learning Objectives

After completing this unit, you’ll be able to:
  • Describe how continuous integration benefits you and your customers.
  • List the tools needed for continuous integration with Salesforce DX.

What Is Continuous Integration?

Continuous integration (CI) is a software development best practice. When using CI, all code that development teams produce is merged into a central repository, where an automated build can validate it. This practice helps development teams detect problems, identify bugs, and fix those problems and bugs before releasing changes to their customers.

CI is like an insurance policy. Would you risk driving around town without car insurance? No way! In today's world of agile development, it's easy to push changes to your users. With a CI system in place, even the smallest change is processed to ensure your system continues to work flawlessly. Early detection and fixes are key for happy software stakeholders (that's a fancy way of saying "your customers").

So now you know that CI can save your company money. Next, we’re going to walk you through the steps to set up CI with Salesforce DX. If you remember from an earlier module, Salesforce DX lets you pick the tools you want to use. This flexibility means that you can use any CI or continuous delivery (CD) service you want. For this module, we decided to take advantage of two cloud-based solutions:

  • GitHub, a version control system (VCS), for our central repository

  • Travis CI, which works well with GitHub

Before You Get Started

Ensure that you have these things set up so you can follow along with the steps in this module:

If you’ve completed the App Development with Salesforce DX module, you likely already have the tools that you need to complete this module. If you’re unsure, we recommend doing that module first.

Create a GitHub Account and Install Git

Although you can use any VCS, we like using Git with GitHub, which makes it easy for you and your team to work together on projects. In our case, we’re going to have you grab a sample application from GitHub.

Let’s get started!

  1. Join GitHub.
  2. Follow the instructions on GitHub to install Git on your machine.
Note

Note

In this module, we’ll use HTTP to grab our sample from the GitHub repo. In the real world, we recommend setting up SSH. SSH is the easiest way to securely connect to the code you store in GitHub. Follow GitHub’s instructions to add an SSH key to your GitHub account.

Get the Sample App from GitHub

Now that you have GitHub set up, let’s grab the application used for this project. To do so, fork and clone an existing GitHub repository.

  1. Open the sfdx-travisci GitHub repo.
  2. In the repo, click Fork.
  3. Choose your GitHub account to fork to.

    The fork gives you your own copy of the repository.

  4. From a command window, run:
    git clone https://github.com/<GH_username>/sfdx-travisci.git

    Replace <GH_username> with your GitHub username. This command grabs everything out of the repository and stores it locally. This repository includes a Salesforce DX project, already configured.

    Note

    Note

    You can also download the .zip file and unzip it locally.

  5. Change to the Travis CI sample app directory.

Create a Travis CI Account

Getting started with Travis CI is easy. You’ll use your GitHub credentials to log in.

  1. Go to the Travis CI website and click Sign Up.
  2. Click Authorize travis-ci to log in with your GitHub credentials, then enter your GitHub password.

    You’re actually on GitHub.com at this point; Travis CI never sees your login information.

  3. When you’ve logged in, click your picture to go to profile settings.
  4. Find the sfdx-travisci repository and turn on Travis CI for your repo.

    Travis CI repo toggle switch

    Sometimes it takes several minutes to sync Travis CI and GitHub, so hang tight if you don’t immediately see your repository.

That’s it. You’ve now set up Travis CI to track your GitHub repository. Later we’ll review the .travis.yml configuration file, which documents the steps for the CI process.

Install the Travis CI Client

Install the Travis CI command-line interface (CLI). If you’re using macOS, your configuration could require you to run the installation commands preceded by sudo.

To confirm that the installation succeeded, run the travis command in the command window:

travis

If the installation was successful, you see the available Travis CI commands in the output.

Travis command output

retargeting