Onboarding Guide
Walk through integrating code coverage into pipelines
This guide walks you through integrating code coverage into your Harness CI pipeline.
What you will learn from this topic
How to connect your repository for coverage tracking
How to modify your pipeline to upload coverage reports for Python, Java, Go, and Node.js
How to configure PR comment integration and quality gates
Before you begin
A code repository connected via a Harness connector or a native Harness Code Repository
Existing tests in your codebase
A valid Harness CI pipeline and license
Step 1: connect your repository
Code coverage requires a repository connection to track changes and calculate patch coverage.
In your Harness pipeline, go to the Build stage
Configure the Codebase section with your Git repository connector
Ensure the connector has:
Read access to your repository
(Optional) Write access to pull request comments (or equivalent)
(Optional) Write access to status checks (or equivalent)
Go to Configure codebase for configuring codebases.
Step 2: modify your pipeline to upload coverage
Add coverage commands to the Run step where you execute tests. The approach varies by language:
Step 3: configure PR comment integration (optional)
When Harness has write access to PRs and status checks, it posts coverage results as comments on your pull requests.
PR comments show:
Total coverage percentage
Patch coverage percentage
Coverage diff compared to the base branch
Per-file coverage breakdown
Go to SCM status checks for more information on PR comments.
Step 4: set up CI pipeline quality gates (optional)
Enforce minimum coverage thresholds to prevent merging code that reduces coverage.
Add a quality gate check after uploading coverage:
This command:
Waits for coverage data to be processed
Checks that total coverage is greater than 70%
Checks that patch coverage (for PRs) is greater than 80%
Fails the pipeline if thresholds are not met
You can specify one or both thresholds:
Verify your setup
After configuring coverage:
Run your pipeline on a pull request
Go to the Coverage tab in the execution details
Verify coverage metrics appear correctly
Check your pull request for coverage comments (if configured)
Verify you see the coverage UI under Code Quality → Coverage.
Troubleshooting
Next steps
Go to Advanced Settings to configure file exclusions and rollout strategies
Go to Understanding Results to learn how to interpret coverage metrics
Last updated
Was this helpful?