---
title: Azure Devops (Visual Studio Team Services) Integration
description: Integrate TestingBot with Azure Devops - Visual Studio Team Services.
source_url:
  html: https://testingbot.com/support/integrations/ci-cd/azure
  md: https://testingbot.com/support/integrations/ci-cd/azure/index.md
---
# Azure Devops (VSTS)

Azure Devops (formerly Team Foundation Server and Visual Studio Team System) is a CI service owned by Microsoft.

TestingBot has a [Marketplace Extension](https://marketplace.visualstudio.com/items?itemName=testingbot.testingbot-tasks) that offers some features to better integrate TestingBot with Azure Devops:

- Set TestingBot environment variables (`TB_KEY` and `TB_SECRET`) to be used by your tests. 
- Embed overview of your tests in Azure Devops. 
- Start/Stop [TestingBot Tunnel](https://testingbot.com/support/tunnel) for specific builds. 

## Installing Azure Pipelines extension

1. Make sure you are logged in to Azure Devops.   
 Then please go to the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=testingbot.testingbot-tasks) and download the TestingBot extension. 

2. Click on **Get it free** to install the extension.

3. Using the **Select an Azure DevOps organization** drop-down menu, choose the organization and click **install**.

## Configure the pipeline

Now that the TestingBot extension has been installed, you'll need to configure the **Service Connection**.

- Go to **Project Settings** and select **Service connections**.

- Click **New Service Connection**.   
 You can now add the **TestingBot credentials**. ![service connection](https://testingbot.com/assets/support/azure/serviceconnection-28f4f9d1e45db5b5e792de642feec247ddbaab1b80b4e26da2d3118cd8c27d60.png) ![new service connection](https://testingbot.com/assets/support/azure/newserviceconnection-fd4a7a4304e4de7459212127db1320f8c6a2561a1768113d7cb4ddc7bbd6c2de.png)

- Add a **Service connection name** and click **Save**.

Now that we've set up the Service Connection, we can go ahead and add the custom TestingBot task to the `azure-pipelines.yml` file.   
 To do this, you can edit the file in your favorite editor, or through the YAML editor on Azure Devops.

### TestingBot Task

In the `steps` block, you can now add the TBMain task, either via the Task menu in the Azure Devops page or by editing the file:

    - task: TBMain@0
      inputs:
        connectedServiceName: '{your service-connection-name}'

 ![TestingBot task](https://testingbot.com/assets/support/azure/task-df76373dd1b555f4fbf1366266775bb4bea3cbc49e8c33e8b1c3a931656eb327.png) ![TestingBot credentials](https://testingbot.com/assets/support/azure/credentials-f7f03c7c8483411685fcc4cdd91907b104f84cbd7ef83a12f931eeaed9d37813.png)
## Viewing Test Results

The extension allows you to view test results from Azure.   
 To enable this, make sure you followed the previous steps and modify your existing test or test suite to send an extra capability to TestingBot: `build`.

The extension makes the following environment variables available for your test cases:

- `TB_KEY`
- `TB_SECRET`
- `TB_BUILD_NAME`

The `TB_BUILD_NAME` environment variable needs to be passed as a `build` capability, for example:

    ChromeOptions options = new ChromeOptions();
    options.setCapability("browserVersion", "latest");
    options.setCapability("platformName", "WIN11");
    options.setCapability("name", methodName);
    // this capability below will make sure the reporting works
    options.setCapability("build", System.getenv("TB_BUILD_NAME"));
    
    webDriver.set(new RemoteWebDriver(
      new URL("https://" + System.getenv("TB_KEY") + ":" + System.getenv("TB_SECRET") + "@hub.testingbot.com/wd/hub"),
    options));

It is **important** to pass the `TB_BUILD_NAME` environment variable as a `build` capability for the reporting to work.

Once the build is complete, you will see a **TestingBot** tab. This will show an overview of the tests for this build.

 ![TestingBot embed test results](https://testingbot.com/assets/support/azure/embed-5c5a048690d9148927bbbb882d02f5163b343531236578afd29eeaeb736bb234.png)
## Enable TestingBot Tunnel

[TestingBot Tunnel](https://testingbot.com/support/tunnel) allows you to run tests against web applications hosted on private, staging or development machines.   
 To enable the TestingBot Tunnel in Azure, make sure the **TestingBot Tunnel checkbox** is checked.

 ![TestingBot enable tunnel](https://testingbot.com/assets/support/azure/enabletunnel-34e07bb4d8b6335bd9218f2b57ab9a6a51fa7f75212be0ff385942f38a2397f3.png)

To use the Tunnel with your test, make sure to edit your test to use the Tunnel IP (`localhost:4445`):

    ChromeOptions options = new ChromeOptions();
    options.setCapability("browserVersion", "latest");
    options.setCapability("platformName", "WIN11");
    options.setCapability("name", methodName);
    // this capability below will make sure the reporting works
    options.setCapability("build", System.getenv("TB_BUILD_NAME"));
    
    webDriver.set(new RemoteWebDriver(
      new URL("http://" + System.getenv("TB_KEY") + ":" + System.getenv("TB_SECRET") + "@localhost:4445/wd/hub"),
    options));

### Stop Tunnel

It's important to close the tunnel at the end of your test. To do this, please add the **Stop TestingBot Tunnel task** in your `azure-pipelines.yml` file.

Make sure to add the `TBStopTunnel@0` after your other tasks.

 ![TestingBot stop tunnel](https://testingbot.com/assets/support/azure/stoptunnel-5255e360c29c8671ec9dbcbf6dfa1a627b998c73e71f631efb162bdbcb2c27ff.png)
### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
