Skip to main content

Installation

Before using CodeAnt Coverage Upload in your Azure Pipelines, you need to install the CodeAnt extension from the Azure DevOps Marketplace:
  1. Go to the Azure DevOps Marketplace and search for “CodeAnt AI” or directly download from here
  2. Click Get it free
  3. Select your Azure DevOps organization
  4. Click Install
Once installed, the 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 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 name
  • BUILD_REPOSITORY_NAME - Repository name
  • BUILD_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)

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


Scenario 4: GitLab Repository + Azure DevOps Pipeline

Parameters for GitLab


Scenario 5: Bitbucket Repository + Azure DevOps Pipeline

Parameters for Bitbucket


Task Parameters Reference

Required Parameters

Optional Parameters


Azure DevOps Pipelines Workflow

This pipeline triggers on pushes to the specified branch and performs the following steps:
  1. Runs tests and generates a coverage report
  2. 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 the module and modulePath parameters to track coverage for individual modules:

Monorepo Parameters

Multiple Modules Example

For monorepos with multiple modules, give each upload its own module and modulePath. CodeAnt AI keeps the reports separate so each module is tracked, displayed, and gated independently. Without module, every upload writes to the same key and later steps overwrite earlier ones.
Recommended: a single job with strategy.matrix
Instead of duplicating the upload step per module, define it once and fan it out with strategy.matrix. Each matrix entry becomes its own parallel job; adding a new module is one new entry.
Azure spawns one job per matrix entry - Coverage backend, Coverage frontend, etc. - and each runs the upload independently with its own module, modulePath, and coverageFile.
Alternative: one step per module
If you prefer the explicit form (e.g. each module has a different test command that can’t be parameterized cleanly), call the task once per module:
Important:
  • In Project → Pipelines → Library, add a secret variable named CODEANT_TOKEN with your CodeAnt token (cdt_…). See API Tokens for how to create one.

How it works

  1. Setup environment The task automatically extracts organization, project, and repository information from Azure DevOps built-in variables.
  2. Download script The task fetches the coverage upload script (upload_coverage.sh) from the CodeAnt API endpoint.
  3. Upload coverage The script uploads your coverage report to CodeAnt AI for analysis and tracking.
  4. Pipeline feedback
    • Success: Coverage uploaded successfully
    • Failure: Upload fails due to authentication or file issues

Coverage Formats Supported

Important: Only XML format is supported for coverage reports.
  • Cobertura XML (most common, generated by coverage xml)
  • JaCoCo XML (Java 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

When you assign source to ”.” , It checks for every python file in the root folder and its sub directories. You can omit some directories by placing them in the omit section of the file.

How it works

With the above configuration:
  1. coverage run -m pytest tests/ will count every .py under the workspace as “valid” lines except for those in the omitted directories.
  2. Lines actually executed by your tests are marked “covered.”
  3. coverage xml -o coverage.xml produces a Cobertura-style report reflecting true coverage over the entire codebase.
  4. Using this coverage xml, we calculate the coverage percentage and the status check will be done on every new push to the branch.

Windows Runner Configuration

If you’re using Windows runner (windows-latest) instead of Linux runner, make the following change:

Change Required

Update pool configuration:

Key Difference


On-Premise Deployment

If you are using a self-hosted CodeAnt instance, you can specify a custom API endpoint using the apiBase parameter:
Note: The apiBase parameter is only required for on-premise deployments. Cloud users do not need to configure this.

Token permission

This pipeline authenticates with a CodeAnt API token (cdt_…). If the token is scoped, give it the Codeant CI/CD role - it covers scans, quality gates, and test-coverage upload - scoped to the repositories this pipeline runs on (or All repositories). A token missing the required permission is rejected with an HTTP 403 token_scope_forbidden error that names the permission it needs. See API token permissions.