For the complete documentation index, see llms.txt. This page is also available as Markdown.

Advanced Settings

File exclusions, multi-pipeline rollout, and advanced configuration

Configure advanced code coverage options for complex scenarios.

What you will learn from this topic

  • How to exclude files from coverage calculations at the repo level and in your build tool

  • How to roll out code coverage across your organization using pipeline templates

  • Advanced CLI parameters for uploading coverage and enforcing quality gates

Before you begin

  • Complete the Onboarding Guide to have code coverage working in at least one pipeline

  • A valid Harness CI license

File exclusions

Exclude files from coverage calculations to focus on relevant source code.

Repo level exclusions

Files can be excluded using the exclusions settings found in the Settings tab.

Coverage settings UI showing file exclusions configuration

Specify files to exclude using glob or regex. To use regex, prepend line items with "regex:" with no space afterwards.

Coverage tool exclusions

You can also bake in exclusion rules by providing instructions to your test runner (this happens in your pipeline and is independent of Harness tooling).

Python (pytest with coverage.py):

Create a .coveragerc file:

Java (JaCoCo with Gradle):

Configure in build.gradle:

Go:

Tag files you want to leave out of the coverage profile with a build constraint:

Run tests without -tags integration. Those files are not compiled, so they stay out of the coverage profile:

JavaScript (Jest):

Configure in jest.config.js:

Rolling out code coverage across your organization

Pipeline templates

Create reusable pipeline templates to standardize coverage across teams:

  1. Create a template with a dedicated coverage steps (using the instructions above)

  2. Share the template across projects

Go to Pipeline Templates for more information.

Advanced CLI options

Upload parameters

Parameter
Required
Description

--file

No

Path to coverage file (can be specified multiple times for multi-file upload)

--base

No

Base branch for diff coverage tracking (e.g., main, origin/main)

--patch

No

Only include coverage for lines changed in the diff (requires --base)

--verbose

No

Enable verbose output for debugging (true or false)

--log-level

No

Set log level: debug, info, warn, error (default: info)

--owner

No

Specify identifier of repo SCM owner (<owner>/<repo>)

--identifier

No

Specify the repository name

Quality gate parameters

Parameter
Required
Description

--gt

No

Minimum total coverage percentage required

--patch-gt

No

Minimum patch coverage percentage required (for PRs)

--timeout

No

How long to wait for coverage data (e.g., 1m, 30s). Default: 30s

Troubleshooting

Coverage shows 0% after exclusions

Verify exclusion patterns do not exclude all source files. Check that your glob or regex pattern matches only the files you intend to exclude, not your entire source directory.

Quality gate times out

Increase the --timeout value or check network connectivity. The default timeout is 30s; for larger repositories or slower networks, try --timeout=2m.

Multiple coverage files conflict

Upload files in separate steps with distinct tags to prevent them from overwriting each other.

Base branch not found

Ensure the branch name includes the remote prefix, for example origin/main instead of main.

Coverage was uploaded for the wrong repository

Use the --owner parameter to force linking with the correct repository: hcli cov upload --owner=<owner>/<repo>.

Files are not getting excluded

Use full globs (e.g. **/) or regex (e.g. regex:^) to match against files to exclude. Partial path segments without **/ may not match nested files.

Coverage does not show on the default branch

Ensure you are uploading coverage reports on CI runs on your default branch, not only on pull request builds.

Next steps

Last updated

Was this helpful?