> For the complete documentation index, see [llms.txt](https://docs.cloudbeat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudbeat.io/features/integrations/ci-cd-tools/azure-tfs.md).

# Azure DevOps

Integrating Azure with CloudBeat enables automated cloud testing within your CI/CD pipeline. It streamlines test execution, provides detailed reporting, and ensures faster feedback.

### Prerequisites&#x20;

In order to run a test case, we need 3 things: Cloudbeat API Key, test case id and test type.

### Cloudbeat API Key

To find your api key, go to Account > Settings > Security

or follow this link: <https://app.cloudbeat.io/#/settings/security/>

### Test Case ID

To find a case id simply open cases and open the case you want to run.

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FKd8R3Uf6SDetgI7Lbugb%2Fimage.png?alt=media&amp;token=0917f6b7-2c98-42fe-bea4-c1bd908734a1" alt=""><figcaption></figcaption></figure>

### Test Type

You can choose between a case, which is used for a singular test, or suite for multiple tests.

## Azure Pipeline

**Start by creating a new pipeline in Azure**

* **Log In and Navigate**
  * Go to [Azure DevOps](https://dev.azure.com/), log in, and open your project.
* **Go to Pipelines**
  * Click on **Pipelines** in the left-hand menu, then choose **New Pipeline**.
* **Select Source Repository**
  * Choose the repository where your code is stored (e.g., Azure Repos or GitHub).
* **Choose the Classic Editor**
  * When setting up the pipeline, select **Use the Classic Editor** instead of YAML.
* **Configure Pipeline Settings**
  * Set the pipeline name (e.g., `Cloudbeat-cli Run Test Example`).
  * Under **Agent Pool**, choose **Azure Pipelines** and select the **Agent Specification** (e.g., `ubuntu-22.04`).

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FHv2sdT32FnkrCnxCzpf3%2Fimage.png?alt=media&amp;token=9dcf8c42-dd1a-4dfa-b7a0-8654040cda2c" alt=""><figcaption></figcaption></figure>

* **Select the Repository Source**:
  * In the pipeline editor, under **Get Sources**, click the edit icon.
  * Choose **GitHub** (or another repository type based on your project).
* **Authorize the Connection**:
  * If GitHub is selected, ensure it’s authorized using an access token. Click **Change** to modify or reauthorize if necessary.
* **Set Repository and Branch**:
  * Repository: Select the specific GitHub repository (e.g., `oxygenhq/docs`).
  * Default Branch: Specify the branch to build from (e.g., `refs/heads/master`).
* **Adjust Source Settings**:
  * **Clean**: Set to `false` (default) to avoid cleaning the workspace before building. Change to `true` if a fresh workspace is needed for every run.
  * **Tag Sources**: Choose whether to tag the repository:
    * **Never**: Don’t tag builds (default).
    * **On Success**: Tag only successful builds.
    * **Always**: Tag every build.
* **Report Build Status**:
  * Check the box to report the build status back to GitHub.

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FPsFGDKA224aNagwyK6Jj%2Fimage.png?alt=media&amp;token=264bd244-04a4-42e1-87ac-59eec4219dac" alt=""><figcaption></figcaption></figure>

## Define Variables

You can create variables to store data such as API keys and other data to use across the tasks.

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FfAUZjnYFFp1w0VQbRVAF%2F2024-11-20%2001_43_52-Window.jpg?alt=media&amp;token=fb1c3c52-136c-4e5a-868b-a7333f366856" alt=""><figcaption></figcaption></figure>

## Add Agent Job

First we need to add a command which will install the cloudbeat cli

### Install Cloudbeat CLI

Add a command line task, name it "Install @cloudbeat/cli"

Add the script:

`npm install -g @cloudbeat/cli`

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2Fy4POv6GrcTDtJLyoYLCh%2Fimage.png?alt=media&amp;token=2ea99acb-c413-400f-b75e-f1d32ed93263" alt=""><figcaption></figcaption></figure>

### Run Test Case

To run our test, we need to add another command line and pass in the test type, id, and api key:

cloudbeat-cli start testType testId --apiKey=apiKey

But since we defined our variables, we can add this to the script:

`cloudbeat-cli start $(cbTestType) $(cbTestId) --apiKey=$(cbApiKey)`

when the test ends, it will create an JUnit XML results file

### Publish Test Results

Lastly we need to publish the results. Add another task called "Publish Test Results":

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FkWpTnbjcCv3KOyVUrLzl%2Fimage.png?alt=media&amp;token=52080603-43e3-43c9-855a-ae8101a74026" alt=""><figcaption></figcaption></figure>

## Run Pipeline

Press on Queue and Run

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FUjBrwMlZHZwsGhW8dPF9%2Fimage.png?alt=media&amp;token=215621ce-543c-442b-8d69-f5a4e4b5fee3" alt=""><figcaption></figcaption></figure>

Inside Cloudbeat, you will see the test case starting

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2FQIW6ettpRp0vBUPF4xan%2Fimage.png?alt=media&amp;token=58ebfc4d-8852-4238-bb67-c43f147f0e80" alt=""><figcaption></figcaption></figure>

After it's finished, you can see the results by following the link under Publish Test Results:

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2F0awxvEBCS7LAKZV397mK%2Fimage.png?alt=media&amp;token=b94aa722-7583-4f03-b9cc-4f7f19648a6f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1835512707-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LuDeDlFo7eLPBFbUgtb%2Fuploads%2Fq8DLNNhpc5w2VN1XzabJ%2Fimage.png?alt=media&amp;token=5e7ff4d4-9903-4b96-b6a3-db22077fe7e1" alt=""><figcaption></figcaption></figure>
