# Travis CI

> Upload JUnit test results from a Travis CI build to an Arcus test run so test case statuses update automatically.

Integrating Travis CI with Arcus by Testsigma uploads your JUnit test results to a test run at the end of a build, so test case statuses update automatically.

## Prerequisites

- A Travis CI account.
- A project in Arcus by Testsigma with at least one [test run](https://testsigma.com/docs/arcus/v2/run-tests/test-runs/).
- An Arcus by Testsigma [API token](https://testsigma.com/docs/arcus/v2/settings/api-keys/).

## Store the API token in Travis CI

1. Open your project in Travis CI.

2. Open **Settings**.

3. Under **Environment Variables**, add a variable. Enter `TESTSIGMA_API_TOKEN` in **Name** and your Arcus by Testsigma API token in **Value**.

Turn off **Display value in build log** for this variable. Left on, your API token appears in the build log.

## Configure the pipeline

1. In your repository, open or create `.travis.yml` in the root directory.

2. Add the following, then replace the 2 placeholders as described below.

```yaml
language: java

jdk:
  - openjdk8

env:
  global:
    - TESTSIGMA_API_TOKEN=${TESTSIGMA_API_TOKEN}

script:
  - mvn clean package

after_success:
  - curl --location 'https://arcus.testsigma.com/api/v1/projects/<Project_ID>/junit-import/test-run/<Run_ID>' --header "Authorization: Bearer $TESTSIGMA_API_TOKEN" --form "junit_xml=@target/surefire-reports/TEST-MyTests.xml"
```

- Replace `` with your project ID, which you can retrieve using the Arcus by Testsigma APIs.
- Replace `` with the run ID, which appears in the URL when you view a test run: `https://test-management.testsigma.com/ui/test_runs//`.
- Point `junit_xml` at the path your build writes its JUnit XML report to.

The upload runs under `after_success`, so it is skipped when the build fails.

## Trigger a build

Push a commit to `main`, or to whichever branch Travis CI is configured to watch. Travis CI runs the build, and when it finishes the test run in Arcus by Testsigma updates with the execution results.
