# Azure DevOps

> Upload JUnit test results from an Azure DevOps pipeline run to an Arcus test run so test case statuses update automatically.

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

## Prerequisites

- An Azure DevOps 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 Azure DevOps

The pipeline reads the token from a pipeline variable named `TESTSIGMA_API_TOKEN`, so add it in Azure DevOps and mark it as a secret.

## Configure the pipeline

1. In Azure DevOps, open your pipeline.

2. Click **Edit** in the top right.

3. Replace the contents of `azure-pipelines.yml` with the following, then replace the 2 placeholders as described below.

```yaml
trigger:
  - master

pool:
  vmImage: ubuntu-latest

variables:
  TESTSIGMA_API_TOKEN: $(TESTSIGMA_API_TOKEN)

steps:
  - task: Maven@3
    inputs:
      mavenPomFile: 'pom.xml'
      mavenOptions: '-Xmx3072m'
      javaHomeOption: 'JDKVersion'
      jdkVersionOption: '1.8'
      jdkArchitectureOption: 'x64'
      publishJUnitResults: true
      testResultsFiles: '**/surefire-reports/TEST-*.xml'
      goals: 'package'
    continueOnError: true
    displayName: 'Build and test with Maven'

  - bash: |
      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/report.xml"
    env:
      TESTSIGMA_API_TOKEN: $(TESTSIGMA_API_TOKEN)
    displayName: 'Upload test results to Testsigma'
```

- 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. For a Maven build this is under `surefire-reports`.
- Change `master` under `trigger` if your target branch is named something else.

## Trigger a build

In your Azure DevOps pipeline, click **Run pipeline**.

When the build finishes, the test run in Arcus by Testsigma updates with the execution results.
