Documentation Index
Fetch the complete documentation index at: https://docs.codeant.ai/llms.txt
Use this file to discover all available pages before exploring further.
CodeAnt AI Coverage Upload for GitLab
Upload test coverage reports to CodeAnt AI for comprehensive analysis, visualization, and tracking of your code coverage metrics.Features
- 📊 Upload coverage reports in XML format (Cobertura XML, JaCoCo XML)
- 🔍 Automatic coverage analysis and insights
- 📈 Track coverage trends over time
- 🎯 Integration with merge requests
- 🚀 Easy setup with minimal configuration
Usage
Basic Example
Advanced Example
Inputs
ACCESS_TOKEN must be added as a project (or group) CI/CD variable so it can be masked — never paste it into your .gitlab-ci.yml. The remaining variables go under variables: inside the upload job.
Set as a CI/CD variable
| Variable | Description | Required |
|---|---|---|
ACCESS_TOKEN | GitLab access token used to authenticate with CodeAnt AI. The script reads this exact name. | Yes |
variables: in your .gitlab-ci.yml
| Variable | Description | Required | Default |
|---|---|---|---|
COVERAGE_FILE | Path to the coverage XML file (e.g. coverage.xml). | Yes | coverage.xml |
API_BASE | CodeAnt AI API base URL. | No | https://api.codeant.ai |
PLATFORM | Git platform (github, gitlab, bitbucket). | No | gitlab |
BASE_URL | Base URL of the git platform. Leave at the default for self-hosted GitLab — $CI_SERVER_URL is set automatically per pipeline. | No | $CI_SERVER_URL |
MODULE | Module name for monorepo setups (e.g. backend, frontend). Required when uploading multiple coverage files for the same commit so reports don’t collide. | No | - |
MODULE_PATH | Module path used to resolve files in a monorepo (e.g. services/backend). Defaults to MODULE if omitted. | No | MODULE |
Supported Coverage Formats
Important: Only XML format is supported for coverage reports.
- Cobertura XML (.xml)
- JaCoCo XML
Setup
1. Get Your GitLab Access Token
- Log in to your GitLab account
- Go to Edit profile (User Settings) > Access Tokens
- Create a new token with the
apiscope (This grants full read/write access to the API and repositories) - Copy the token
2. Generate Coverage Report
First, ensure your test suite generates a coverage report. Here are examples for common languages: Python (pytest)3. Add CI/CD Variables
Add your GitLab Access Token to your GitLab project:- Go to your repository Settings
- Navigate to CI/CD > Variables
- Click “Add variable”
- Key:
ACCESS_TOKEN(this is the variable name the included template reads) - Value: Your GitLab Access Token
- Protected: Yes (recommended)
- Masked: Yes (recommended)
4. Configure Pipeline
Add the template to your.gitlab-ci.yml as shown in the usage examples above.
How It Works
- The job fetches the latest coverage upload script from CodeAnt AI
- Decodes and prepares the script for execution
- Uploads your coverage report along with commit and branch information
- CodeAnt AI processes the report and provides analysis
Examples
Python Project
Node.js Project
Java Project
Multiple Coverage Files (Monorepo)
When a single commit produces several coverage reports — for example one per service in a monorepo — give each upload its ownMODULE and MODULE_PATH. 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 jobs overwrite earlier ones.
MODULEis the logical name shown in the UI (e.g.backend,frontend).MODULE_PATHis the directory used to resolve source files referenced in the coverage XML (e.g.services/backend). If your XML’sfilenameattributes are relative to the module root, setMODULE_PATHto that root.
Recommended: a single job with parallel:matrix
Instead of duplicating the upload block per module, define it once and fan it out with parallel:matrix. Each matrix entry becomes its own parallel job; adding a new module is one new entry instead of an entire job stanza.
The job name codeant_coverage matches the one shipped by the included template, so this definition replaces it. Provide your own test_* jobs that emit each module’s coverage XML at the path referenced by COVERAGE_FILE.
codeant_coverage: [backend, services/backend, services/backend/coverage.xml], codeant_coverage: [frontend, …], etc. — and each one runs the upload independently with its own MODULE, MODULE_PATH, and COVERAGE_FILE.
Alternative: one job per module
If you prefer the explicit form (e.g. you want each module gated by a different upstreamneeds:), define a job per module:
Troubleshooting
Coverage file not found- Ensure the
COVERAGE_FILEpath is correct and the file exists as an artifact from a previous job.
Invalid access token
- Verify that your
ACCESS_TOKENis valid and that its owner has access to the project — the validator callsGET /api/v4/projects/{repo}with the token and rejects anything other than200. A token can be alive (200 on/api/v4/user) but still 404 on the project if its owner was removed from the project. - If you have an
ACCESS_TOKENdefined as a project-level CI/CD variable, it overrides anyACCESS_TOKENset in.gitlab-ci.yml(project-level CI variables take precedence over YAML variables). Update or remove the project-level variable rather than trying to override it from YAML.
- Check that the CodeAnt AI API is accessible from your runner environment.
Contributing
Contributions are welcome! Please feel free to submit a Merge Request.License
This project is licensed under the MIT License - see the LICENSE file for details.Support
- 📧 Email: support@codeant.ai
- 📚 Documentation: https://docs.codeant.ai
- 🐛 Issues: https://gitlab.com/codeant-pipelines/code-coverage-gitlab
Related
- CodeAnt AI - AI-powered code analysis platform
- GitLab CI/CD Documentation