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:
ScenarioRepository LocationPipeline LocationConfiguration
Scenario 1Azure ReposAzure DevOpsAuto-detected (default)
Scenario 2Azure Repos (TFS / Azure DevOps Server – on-prem)Azure DevOps Server (TFS)Requires explicit platform, repo, commitId, and baseUrl inputs
Scenario 3GitHubAzure DevOpsRequires platform, baseUrl, and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available.
Scenario 4GitLabAzure DevOpsRequires platform, baseUrl, and repo inputs. commitId auto-detected from BUILD_SOURCEVERSION if available.
Scenario 5BitbucketAzure DevOpsRequires 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:
- task: CodeAntCoverageUpload@1
  inputs:
    accessToken: $(ACCESS_TOKEN)
    coverageFile: 'coverage.xml'
  displayName: 'Upload Coverage to CodeAnt'
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.
- task: CodeAntCoverageUpload@1
  inputs:
    accessToken: $(ACCESS_TOKEN)
    platform: 'azuredevops'
    baseUrl: 'https://tfs.example.com:8443/tfs'
    repo: 'MyCollection/MyProject/MyRepository'
    commitId: '$(Build.SourceVersion)'
    coverageFile: 'coverage.xml'
  displayName: 'Upload Coverage to CodeAnt'

Parameters for Azure DevOps Server (TFS)

ParameterValueDescription
platformazuredevopsSpecifies Azure DevOps as the repository provider
baseUrlhttps://tfs.example.com:8443/tfsBase URL of your on-premise Azure DevOps Server / TFS instance
repocollection/project/repoRepository 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

- task: CodeAntCoverageUpload@1
  inputs:
    accessToken: $(ACCESS_TOKEN_GITHUB)
    platform: 'github'
    baseUrl: 'https://github.com'
    repo: 'myorg/my-repo'
    commitId: '$(Build.SourceVersion)'
    coverageFile: 'coverage/cobertura-coverage.xml'
  displayName: 'Upload Coverage to CodeAnt'

Parameters for GitHub

ParameterValueDescription
platformgithubSpecifies GitHub as the repository provider
baseUrlhttps://github.comBase URL of the GitHub platform
repoowner/repoRepository 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

- task: CodeAntCoverageUpload@1
  inputs:
    accessToken: $(ACCESS_TOKEN_GITLAB)
    platform: 'gitlab'
    baseUrl: 'https://gitlab.com'
    repo: 'mygroup/my-project'
    commitId: '$(Build.SourceVersion)'
    coverageFile: 'coverage.xml'
  displayName: 'Upload Coverage to CodeAnt'

Parameters for GitLab

ParameterValueDescription
platformgitlabSpecifies GitLab as the repository provider
baseUrlhttps://gitlab.comBase URL of the GitLab platform
repogroup/projectRepository 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

- task: CodeAntCoverageUpload@1
  inputs:
    accessToken: $(BITBUCKET_ACCESS_TOKEN)
    platform: 'bitbucket'
    baseUrl: 'https://bitbucket.org'
    repo: 'myworkspace/my-repo'
    commitId: '$(Build.SourceVersion)'
    coverageFile: 'coverage.xml'
  displayName: 'Upload Coverage to CodeAnt'

Parameters for Bitbucket

ParameterValueDescription
platformbitbucketSpecifies Bitbucket as the repository provider
baseUrlhttps://bitbucket.orgBase URL of the Bitbucket platform
repoworkspace/repoRepository 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

ParameterDescription
accessTokenPersonal Access Token (PAT) or repository token
coverageFilePath to the coverage file (e.g., coverage.xml, coverage/cobertura-coverage.xml)

Optional Parameters

ParameterDefaultDescription
platformazuredevopsPlatform 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
apiBasehttps://api.codeant.aiBase 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:
  1. Runs tests and generates a coverage report
  2. Uploads the coverage XML to CodeAnt AI
trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  - checkout: self

  # Run tests and generate coverage
  - script: |
      python -m venv .venv
      source .venv/bin/activate
      pip install --upgrade pip
      pip install coverage pytest

      coverage run -m pytest tests/
      coverage xml -o coverage.xml
    displayName: 'Run tests & generate coverage'

  # Upload coverage to CodeAnt
  - task: CodeAntCoverageUpload@1
    inputs:
      accessToken: $(ACCESS_TOKEN)
      coverageFile: 'coverage.xml'
    displayName: 'Upload Coverage to CodeAnt'

With Optional Parameters

You can customize the coverage upload with additional parameters:
steps:
  - checkout: self

  # Run tests and generate coverage
  - script: |
      npm install
      npm test -- --coverage
    displayName: 'Run tests'

  # Upload coverage to CodeAnt
  - task: CodeAntCoverageUpload@1
    inputs:
      accessToken: $(ACCESS_TOKEN)
      coverageFile: 'coverage/coverage.xml'
    displayName: 'Upload Coverage to CodeAnt'

Monorepo Support

For monorepo projects, you can specify the module and modulePath parameters to track coverage for individual modules:
steps:
  - checkout: self

  # Run tests and generate coverage for a specific module
  - script: |
      cd packages/my-module
      npm install
      npm test -- --coverage
    displayName: 'Run tests for my-module'

  # Upload coverage to CodeAnt with module information
  - task: CodeAntCoverageUpload@1
    inputs:
      accessToken: $(ACCESS_TOKEN)
      coverageFile: 'packages/my-module/coverage.xml'
      module: 'my-module-name'
      modulePath: 'packages/my-module'
    displayName: 'Upload Coverage to CodeAnt'

Monorepo Parameters

ParameterDescriptionExample
moduleName of the module in the monorepomy-module-name
modulePathRelative path to the module from repository rootpackages/my-module

Multiple Modules Example

For monorepos with multiple modules, you can upload coverage for each module separately:
steps:
  - checkout: self

  # Module 1: Backend
  - script: |
      cd packages/backend
      npm install
      npm test -- --coverage
    displayName: 'Run backend tests'

  - task: CodeAntCoverageUpload@1
    inputs:
      accessToken: $(ACCESS_TOKEN)
      coverageFile: 'packages/backend/coverage.xml'
      module: 'backend'
      modulePath: 'packages/backend'
    displayName: 'Upload Backend Coverage'

  # Module 2: Frontend
  - script: |
      cd packages/frontend
      npm install
      npm test -- --coverage
    displayName: 'Run frontend tests'

  - task: CodeAntCoverageUpload@1
    inputs:
      accessToken: $(ACCESS_TOKEN)
      coverageFile: 'packages/frontend/coverage.xml'
      module: 'frontend'
      modulePath: 'packages/frontend'
    displayName: 'Upload Frontend Coverage'
Important:
  • In Project → Pipelines → Library, add a secret variable named ACCESS_TOKEN with your personal access token or repo token.

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

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

[run]
# include every Python file under the repo root
source = .

# exclude tests, virtualenvs, build artifacts, etc.
omit =
    */tests/*
    */.venv/*
    */build/*
    */dist/*
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.

On-Premise Deployment

If you are using a self-hosted CodeAnt instance, you can specify a custom API endpoint using the apiBase parameter:
- task: CodeAntCoverageUpload@1
  inputs:
    accessToken: $(ACCESS_TOKEN)
    apiBase: 'https://your-codeant-instance.example.com'
    coverageFile: 'coverage.xml'
  displayName: 'Upload Coverage to CodeAnt (On-Premise)'
Note: The apiBase parameter is only required for on-premise deployments. Cloud users do not need to configure this.