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
codeant-coverage-upload task will be available in all pipelines across your organization.
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: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
Script Parameters
Theupload_coverage.sh script accepts the following parameters:
| Parameter | Flag | Description | Required | Example |
|---|---|---|---|---|
| Access Token | -t, --token | Authentication token for CodeAnt API | Yes | $(ACCESS_TOKEN) |
| Repository | -r, --repo | Repository name in organization/project/repository format | Yes | myorg/myproject/myrepo |
| Commit SHA | -c, --commit | Git commit SHA | Yes | $(Build.SourceVersion) |
| Coverage File | -f, --file | Path to coverage XML file | Yes | coverage.xml |
| Platform | -p, --platform | Git service provider | Yes | azuredevops |
| Branch | -b, --branch | Branch name | No | main |
| Base URL | -u, --url | Base URL for VCS service | No | https://dev.azure.com |
| Module Name | -m, --module | Module name for monorepo structure | No | backend |
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.