<commit_before>---
title: "Integration with Travis CI"
page_id: "integration_with_travis"
warning: false
tags:
  - "newman"

---

Continuous Integration (CI) is a practice that requires developers to integrate code in a shared repository several times a day. 

By committing early and often, the team avoids a ton of technical debt by allowing teams to detect problems early while conflicts are relatively easy to fix. 

Every check-in triggers an automated build process that typically includes testing. And if your commit hasn’t broken anything, might include deployment too.

In general, integrating your [Postman tests](/docs/postman/scripts/test_scripts) with your favorite continuous integration service is the same process as if you’re [running on Jenkins](/docs/postman/collection_runs/integration_with_jenkins), Travis CI, AppVeyor, or any other build system. 

You will set up your CI configuration to run a shell command upon starting your build. The command is a [Newman script that runs your collection](/docs/postman/collection_runs/command_line_integration_with_newman) with the tests, returning a pass or fail exit code that’s logged in your CI system.

In this example, we’ll walk through how to integrate Postman with [Travis CI](https://travis-ci.org/){:target="_blank"}, a continuous integration service that builds and tests projects on GitHub. 

Travis CI runs your tests every time you commit to your GitHub repo. Then it submits a pull request, or some other specified configuration.

[![travis workflow](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_workflow.png)](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_workflow.png)

### Before we get started:

[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/b79dc2835758549eed7e#?env%5Btests%5D=W3siZW5hYmxlZCI6dHJ1ZSwia2V5IjoibGFzdERheS<KEY>)

1. **Select a Postman collection with tests**: For now, let’s assume you already have a Postman collection with tests. Download the sample collection and environment by clicking the Run in Postman button if you want to follow this example.
2. **Set up a GitHub repository**: Travis CI is free for open source projects on GitHub. In this example, we keep our Postman tests in a public GitHub repo.
3. **Set up Travis CI**: Follow the [Travis CI getting started guide](https://docs.travis-ci.com/user/getting-started/){:target="_blank"} for the complete walk through. 

   [Sign in to Travis CI](https://travis-ci.org/auth){:target="_blank"} with your GitHub account. 
   
   Go to your [profile page](https://travis-ci.org/profile){:target="_blank"} and enable Travis CI for the public GitHub repo we set up in the previous step.

### Hooking up Postman to Travis CI

1. [Export the Postman Collection as a JSON file](/docs/postman/collections/data_formats#exporting-and-importing-postman-data) and move the file to your project directory. If you’re using an environment such as this example, [download the Postman environment as a JSON file](/docs/postman/environments_and_globals/manage_environments#manage-environments) and move the file to your project directory as well. 

   In this example, we've moved both files into a directory called `tests` placed in the root of the project repository.

   Remember to add and commit these two files to your repo.

  [![tree view tests directory](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree.png)](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree.png)
  
2. Create a new file called `.travis.yml` and move it to the root of your project repository. 

   Remember to add and commit it to your repo. This file tells Travis CI the programming language for your project and how to  build it. 

   Any step of the build [can be customized](https://docs.travis-ci.com/user/customizing-the-build){:target="_blank"}. These scripts will execute the next time you commit and push a change to your repo.

  [![tree view yml](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree_yml.png)](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree_yml.png)

   In the `.travis.yml` file, add a command to `install` Newman in the CI environment, and then add a `script` telling Newman to run the Postman tests (which we've placed in the `tests` directory). 
  
   Since Travis CI doesn’t know where Newman is located, let's update the `PATH`. In this node.js example, the `newman` tool is located in my `.bin` directory which is located in my `node_modules` directory.
  
   Now, the `.travis.yml` file looks like this for this `node.js` example:

```
language: node_js
node_js:
  - "8.2.1"
<commit_msg>Update integration_with_travis.md<commit_after>---
title: "Integration with Travis CI"
page_id: "integration_with_travis"
warning: false
tags:
  - "newman"

---

Continuous Integration (CI) is a practice that requires developers to integrate code in a shared repository several times a day. 

By committing early and often, the team avoids a ton of technical debt by allowing teams to detect problems early while conflicts are relatively easy to fix. 

Every check-in triggers an automated build process that typically includes testing. And if your commit hasn’t broken anything, might include deployment too.

In general, integrating your [Postman tests](/docs/postman/scripts/test_scripts) with your favorite continuous integration service is the same process as if you’re [running on Jenkins](/docs/postman/collection_runs/integration_with_jenkins), Travis CI, AppVeyor, or any other build system. 

You will set up your CI configuration to run a shell command upon starting your build. The command is a [Newman script that runs your collection](/docs/postman/collection_runs/command_line_integration_with_newman) with the tests, returning a pass or fail exit code that’s logged in your CI system.

In this example, we’ll walk through how to integrate Postman with [Travis CI](https://travis-ci.org/){:target="_blank"}, a continuous integration service that builds and tests projects on GitHub. 

Travis CI runs your tests every time you commit to your GitHub repo. Then it submits a pull request, or some other specified configuration.

[![travis workflow](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_workflow.png)](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_workflow.png)

### Before we get started:

[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/b79dc2835758549eed7e#?env%5Btests%5D=W<KEY>)

1. **Select a Postman collection with tests**: For now, let’s assume you already have a Postman collection with tests. Download the sample collection and environment by clicking the Run in Postman button if you want to follow this example.
2. **Set up a GitHub repository**: Travis CI is free for open source projects on GitHub. In this example, we keep our Postman tests in a public GitHub repo.
3. **Set up Travis CI**: Follow the [Travis CI getting started guide](https://docs.travis-ci.com/user/getting-started/){:target="_blank"} for the complete walk through. 

   [Sign in to Travis CI](https://travis-ci.org/auth){:target="_blank"} with your GitHub account. 
   
   Go to your [profile page](https://travis-ci.org/profile){:target="_blank"} and enable Travis CI for the public GitHub repo we set up in the previous step.

### Hooking up Postman to Travis CI

1. [Export the Postman Collection as a JSON file](/docs/postman/collections/data_formats#exporting-and-importing-postman-data) and move the file to your project directory. If you’re using an environment such as this example, [download the Postman environment as a JSON file](/docs/postman/environments_and_globals/manage_environments#manage-environments) and move the file to your project directory as well. 

   In this example, we've moved both files into a directory called `tests` placed in the root of the project repository.

   Remember to add and commit these two files to your repo.

  [![tree view tests directory](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree.png)](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree.png)
  
2. Create a new file called `.travis.yml` and move it to the root of your project repository. 

   Remember to add and commit it to your repo. This file tells Travis CI the programming language for your project and how to  build it. 

   Any step of the build [can be customized](https://docs.travis-ci.com/user/customizing-the-build){:target="_blank"}. These scripts will execute the next time you commit and push a change to your repo.

  [![tree view yml](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree_yml.png)](https://s3.amazonaws.com/postman-static-getpostman-com/postman-docs/travis_tree_yml.png)

3. In the `.travis.yml` file, add a command to `install` Newman in the CI environment, and then add a `script` telling Newman to run the Postman tests (which we've placed in the `tests` directory). 
  
   Since Travis CI doesn’t know where Newman is located, let's update the `PATH`. In this node.js example, the `newman` tool is located in my `.bin` directory which is located in my `node_modules` directory.
  
   Now, the `.travis.yml` file looks like this for this `node.js` example:

```
language: node_js
node_js:
  - "8.2.1"

{'fraction_non_alphanumeric': 0.08954282711508145, 'fraction_numerical': 0.006831318970047294, 'mean_word_length': 4.624113475177305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 26, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1212665', 'n_tokens_mistral': 2838, 'n_tokens_neox': 2715, 'n_words': 1122}