Installation
Before using CodeAnt Coverage Upload in your Azure Pipelines, you need to install the CodeAnt extension from the Azure DevOps Marketplace:- Go to the Azure DevOps Marketplace and search for “CodeAnt AI” or directly download from here
- Click Get it free
- Select your Azure DevOps organization
- Click Install
CodeAntCoverageUpload@1 task will be available in all pipelines across your organization.
Video Tutorial
Watch this video to learn how to integrate CodeAnt AI into your CI/CD pipelines:Repository Scenarios
CodeAnt Coverage Upload supports multiple repository configurations in Azure DevOps:| Scenario | Repository Location | Pipeline Location | Configuration |
|---|---|---|---|
| Scenario 1 | Azure Repos | Azure DevOps | Auto-detected (default) |
| Scenario 2 | Azure Repos (TFS / Azure DevOps Server – on-prem) | Azure DevOps Server (TFS) | Requires explicit platform, repo, commitId, and baseUrl inputs |
| Scenario 3 | GitHub | Azure DevOps | Requires platform, baseUrl, and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available. |
| Scenario 4 | GitLab | Azure DevOps | Requires platform, baseUrl, and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available. |
| Scenario 5 | Bitbucket | Azure DevOps | Requires platform, baseUrl, and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available. |
Scenario 1: Azure Repos + Azure DevOps Pipeline
When your repository is hosted in Azure Repos:Note: No additional configuration needed. The task automatically extracts information from these Azure DevOps built-in variables:
SYSTEM_TEAMPROJECT- Project nameBUILD_REPOSITORY_NAME- Repository nameBUILD_SOURCEVERSION- Commit SHA
Scenario 2: Azure Repos (TFS / Azure DevOps Server – on-prem) + Azure DevOps Server (TFS) Pipeline
When your repository is hosted in an on-premise Azure DevOps Server (formerly known as Team Foundation Server / TFS), you need to explicitly pass all required parameters including the base URL.Parameters for Azure DevOps Server (TFS)
| Parameter | Value | Description |
|---|---|---|
platform | azuredevops | Specifies Azure DevOps as the repository provider |
baseUrl | https://tfs.example.com:8443/tfs | Base URL of your on-premise Azure DevOps Server / TFS instance |
repo | collection/project/repo | Repository in collection/project/repository-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze |
Note: For on-premise Azure DevOps Server / TFS deployments, all parameters must be explicitly provided as environment variables may differ from Azure DevOps Cloud.
Scenario 3: GitHub Repository + Azure DevOps Pipeline
Parameters for GitHub
| Parameter | Value | Description |
|---|---|---|
platform | github | Specifies GitHub as the repository provider |
baseUrl | https://github.com | Base URL of the GitHub platform |
repo | owner/repo | Repository in owner/repository-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze. Auto-detected from BUILD_SOURCEVERSION if available, otherwise required. |
Scenario 4: GitLab Repository + Azure DevOps Pipeline
Parameters for GitLab
| Parameter | Value | Description |
|---|---|---|
platform | gitlab | Specifies GitLab as the repository provider |
baseUrl | https://gitlab.com | Base URL of the GitLab platform |
repo | group/project | Repository in group/project-name or user/project-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze. Auto-detected from BUILD_SOURCEVERSION if available, otherwise required. |
Scenario 5: Bitbucket Repository + Azure DevOps Pipeline
Parameters for Bitbucket
| Parameter | Value | Description |
|---|---|---|
platform | bitbucket | Specifies Bitbucket as the repository provider |
baseUrl | https://bitbucket.org | Base URL of the Bitbucket platform |
repo | workspace/repo | Repository in workspace/repository-name format |
commitId | $(Build.SourceVersion) | Commit SHA to analyze. Auto-detected from BUILD_SOURCEVERSION if available, otherwise required. |
Task Parameters Reference
Required Parameters
| Parameter | Description |
|---|---|
accessToken | Personal Access Token (PAT) or repository token |
coverageFile | Path to the coverage file (e.g., coverage.xml, coverage/cobertura-coverage.xml) |
Optional Parameters
| Parameter | Default | Description |
|---|---|---|
platform | azuredevops | Platform type: github, gitlab, bitbucket, azuredevops |
baseUrl | (auto-detected) | Base URL for the platform (e.g., https://github.com) |
repo | (auto-detected) | Repository name in owner/repo format |
commitId | (auto-detected) | Commit SHA to analyze |
module | (empty) | Name of the module in a monorepo |
modulePath | (empty) | Relative path to the module from repository root |
apiBase | https://api.codeant.ai | Base URL for CodeAnt API (for on-premise deployments) |
Azure DevOps Pipelines Workflow
This pipeline triggers on pushes to the specified branch and performs the following steps:- Runs tests and generates a coverage report
- Uploads the coverage XML to CodeAnt AI
With Optional Parameters
You can customize the coverage upload with additional parameters:Monorepo Support
For monorepo projects, you can specify themodule and modulePath parameters to track coverage for individual modules:
Monorepo Parameters
| Parameter | Description | Example |
|---|---|---|
module | Name of the module in the monorepo | my-module-name |
modulePath | Relative path to the module from repository root | packages/my-module |
Multiple Modules Example
For monorepos with multiple modules, you can upload coverage for each module separately:Important:
- In Project → Pipelines → Library, add a secret variable named
ACCESS_TOKENwith your personal access token or repo token.
How it works
- Setup environment The task automatically extracts organization, project, and repository information from Azure DevOps built-in variables.
-
Download script
The task fetches the coverage upload script (
upload_coverage.sh) from the CodeAnt API endpoint. - Upload coverage The script uploads your coverage report to CodeAnt AI for analysis and tracking.
-
Pipeline feedback
- Success: Coverage uploaded successfully
- Failure: Upload fails due to authentication or file issues
Coverage Formats Supported
CodeAnt AI supports multiple coverage report formats:- Cobertura XML (most common, generated by
coverage xml) - JaCoCo XML (Java projects)
- Clover XML
- lcov.info (JavaScript/TypeScript projects)
Coverage Config File
You have to create a.coveragerc file in the project’s root folder to include all the source files in the test coverage calculation.
Python Example
How it works
With the above configuration:- coverage run -m pytest tests/ will count every .py under the workspace as “valid” lines except for those in the omitted directories.
- Lines actually executed by your tests are marked “covered.”
- coverage xml -o coverage.xml produces a Cobertura-style report reflecting true coverage over the entire codebase.
- Using this coverage xml, we calculate the coverage percentage and the status check will be done on every new push to the branch.
On-Premise Deployment
If you are using a self-hosted CodeAnt instance, you can specify a custom API endpoint using theapiBase parameter:
Note: The apiBase parameter is only required for on-premise deployments. Cloud users do not need to configure this.