Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 64 additions & 35 deletions src/pages/docs/continuous-integration/azure-devops.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,90 @@ title: "Integrate Testsigma with Azure DevOps"
order: 13.14
metadesc: "How to integrate Testsigma with Azure DevOps"
noindex: false
page_id: "How to Create a Test Plans to run on Local Devices"
page_id: "Integrate Testsigma with Azure DevOps"
search_keyword: "Azure DevOps, Integrations, CI/CD"
warning: false
contextual_links:
- type: section
name: "Contents"
- type: link
name: "Prerequisites:"
name: "Prerequisites"
url: "#prerequisites"
- type: link
name: "How to integrate with Azure DevOps"
url: "#how-to-integrate-with-azure-devops"
name: "Prepare the Shell Script"
url: "#prepare-the-shell-script"
- type: link
name: "Create the Azure DevOps Pipeline"
url: "#create-the-azure-devops-pipeline"
- type: link
name: "Run the Pipeline and View Results"
url: "#run-the-pipeline-and-view-results"
---

---

Microsoft Azure, aka Azure, is a cloud computing service created by Microsoft for building, testing, deploying, and managing applications and services through Microsoft-managed data centers.
Integrate Testsigma with Azure DevOps to trigger Test Plan executions from your CI/CD pipeline. Azure DevOps runs a shell script that calls the Testsigma API to start a Test Plan and fetch its results.

---

> <p id="prerequisites">Prerequisites</p>
>
> Before you begin, ensure that you have referred to:
> 1. [Documentation on generating API keys](https://testsigma.com/docs/configuration/api-keys/).
> 2. <a href="https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/get-test-plan-id.png" rel="nofollow">Documentation on getting test plan ID</a>.
> 1. [Documentation on generic Shell script](https://testsigma.com/docs/continuous-integration/shell-script/) to get the script file.
> 2. [Documentation on generating API keys](https://testsigma.com/docs/configuration/api-keys/).
> 3. [Documentation on getting test plan ID](https://testsigma.com/docs/continuous-integration/get-test-plan-details/).

---
## **How to integrate with Azure DevOps**
1. Login to the Azure DevOps account and create a **Project**. Navigate to Pipelines and click on the **New Pipeline** to get started.

## **Prepare the Shell Script**

1. Copy the Unix shell script from the [documentation on generic Shell script](https://testsigma.com/docs/continuous-integration/shell-script/).

[[info | NOTE:]]
| Use the Unix shell script if your system runs macOS or Linux. Use the script under **For Powershell Script** on the same page if your system runs Windows.

2. Generate an API key from **Configurations > API Keys**. The link is mentioned in the prerequisites.

3. Get the Test Plan ID from the **CI/CD Integrations** tab on the Test Plan details page. The link is mentioned in the prerequisites.

4. Replace **TESTSIGMA\_API\_KEY** and **TESTSIGMA\_TEST\_PLAN_ID** in the script with the values from steps 2 and 3.
![shell script for Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/shell-script-azure-devops.png)

5. Save the script in the code repository that you'll use for the Azure DevOps pipeline. Name it **cicd-api.sh**.

[[info | NOTE:]]
| This script triggers the Test Plan execution and returns the result once the run is complete.

---

## **Create the Azure DevOps Pipeline**

1. Sign in to your Azure DevOps account.

2. Create a **Project**.

3. Navigate to **Pipelines** and click **New Pipeline**.
![create new pipeline azure devops](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/create-new-pipeline-azure-devops.png)

2. Choose the **Version Control System** (VCS) where your application code is stored.
4. Select the version control system (VCS) where your code repository, including **cicd-api.sh**, is stored.
![select version control system in Azure Devops](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/select-version-control-system-azure-devops.png)


[[info | NOTE:]]
| In order to integrate with Azure, you need to have a YAML file in your Code repository. This file contains the details for the CI/CD Integration with Azure DevOps. If not available yet, Azure has an option in which it will create a sample YAML file in your repository once access is given.
| Azure DevOps requires a YAML file in your code repository to configure the CI/CD pipeline. If your repository doesn't have one, Azure DevOps creates a sample YAML file in your repository once you grant access.

3. Choose the repository where your Configuration YAML file is present. Once you select your repository it will take you to the configuration page where you can configure your pipeline.
5. Select the repository that contains your configuration YAML file.
![select repository in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/select-repository-azure-devops.png)

4. On **Configure your pipeline** page, if you already have your YAML file in your repo, you can select the option **Existing Azure Pipeline YAML file**. Otherwise, you can select **Starter Pipeline** to create a sample YAML file in the selected repository.
![configure your pipeline page in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/configure-your-pipeline-azure-devops.png)


In this case, we already had an existing YAML file in the repo. So, once you select the fourth option in the above image, it will take you to a place where you need to enter the branch and path of the YAML file in your repository.
![Select existing pipeline while configuring an existing YAML file in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/configure-pipeline-select-yaml-file-azure-devops.png)
6. On the **Configure your pipeline** page, select **Existing Azure Pipelines YAML file** if your repository already has one, or select **Starter pipeline** to create a sample file.
![configure your pipeline page in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/configure-your-pipeline-azure-devops.png)

**(If using an existing file)**: Enter the branch and path of the YAML file in your repository.
![Select existing pipeline while configuring an existing YAML file in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/configure-pipeline-select-yaml-file-azure-devops.png)

5. Review the CI Configuration after selecting the Branch and Path, click on **Continue**.
7. Review the CI configuration, then click **Continue**.
![Review CI configuration in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/review-ci-configuration-azure-devops.png)

The YAML file contains the following code where you need to enter the filePath of the Generic Shell Script (cicd-api.sh) to run it. For more information on generic shell script, refer to the [documentation generic shell script](https://testsigma.com/docs/continuous-integration/shell-script/). This Shell script is the one that actually triggers the Test Plan execution and gives you the result of Test plan once it's complete.
8. In the YAML file, enter the path to **cicd-api.sh** in the `filePath` field:

```yaml
# Azure Pipelines YAML file
Expand All @@ -69,9 +100,9 @@ steps:
displayName: Run a one-line script

- task: Bash@3
displayName: Run Shell Script (./cd-api.sh)
displayName: Run Shell Script (./cicd-api.sh)
inputs:
filePath: ./cd-api.sh
filePath: ./cicd-api.sh

- task: PublishTestResults@2
displayName: publish test-results
Expand All @@ -80,28 +111,26 @@ steps:
testResultsFiles: '**/*junit-report.xml'
```

---


In order to Trigger a particular test plan, you just need to add your own Test plan Execution id and the API key in the Shell Script (cicd-api.sh). As shown below:
![shell script for Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/shell-script-azure-devops.png)

For more information on configuration of Generic Shell Script, refer to https://testsigma.com/docs/continuous-integration/shell-script/.
## **Run the Pipeline and View Results**

6. Test the configuration once the script is set up and reviewed for the pipeline, and click on the **Run** to start your Job.
1. Click **Run** to start the pipeline job.
![test configuration in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/test-configuration-azure-devops.png)

Once the Run is initiated, you will see this page:
2. Track the run on the pipeline results page.
![set up ci with Azure Pipelines](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/setup-ci-with-azure-pipelines.png)

Once the job has been completed, the Job status will be **Success** as shown in the image below:
3. Once the job completes, the job status shows **Success**.
![Job Status Success in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/job-status-success-azure-devops.png)

7. Once the job is completed we can see the reports in the **Test Plans > Runs**.
4. Navigate to **Test Plans > Runs** to view the reports.
![Test Plans Runs in Pipelines in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/pipelines-testplans-runs-azure-devops.png)

After clicking on **Runs** you can select the Test plan for which you want to view the report and then you will be navigated to the page below, and also you can download the JUnit report in XML format.
5. Select **Runs**, then select the Test Plan whose report you want to view. Download the JUnit report in XML format from this page.
![Junit report in Azure DevOps](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/junit-report-azure-devops.png)

You can use another shell script to convert the JUnit XML format result into an HTML format.

[[info | NOTE:]]
| Use a separate shell script to convert the JUnit XML report into HTML format.

---
Loading