Quality gates
A quality gate is a rule about changed-code coverage: of the lines a change touched, how many did the tests of a build execute? This screen is where you write the rules, see what they say about the latest build, and copy the step that lets CI ask for the same verdict. Open it when you set a coverage bar for merges, or when a pipeline's gate result needs explaining.
Where to find it
Sidebar, group Analyse, Quality gate (route /gate). The page itself is titled Quality gates.
What it shows
Rules
One card per rule, enabled rules first, then by name. Each card shows:
- the name, and scope chips: the branch pattern ("any branch" for
*), the service and the test plan when set; - blocking (a failure fails the pipeline) or advisory (reported, never meant to fail a pipeline);
- PR status when the rule writes its verdict onto the commit;
- off when the rule is disabled (the card is dimmed);
- what it enforces: "changed ≥ N%", "overall ≥ N%", "no failing tests, every test reported", or "enforces nothing".
With no rules, the panel says nothing is enforced and that a pipeline falls back to the project's KPI thresholds.
The latest build, judged
The verdict for the latest run of the project, against the rule you are previewing, or otherwise against whichever rule matches.
- A warning when no rule matched and the project's KPI thresholds answered instead ("Project defaults").
- Verdict: Passed, Failed, Failed (advisory) or No coverage data, with the rule name and the run key.
- Changed-code coverage: the percentage, and covered / measured changed lines.
- Since: the number of commits read, and the date the window starts (30 days back on this screen).
- One row per check (Changed-code coverage, Overall coverage, No failing tests): a tick, a cross or a dash for "not enforced", the measured value and the threshold.
- A Changed-code coverage tree of the changed files, package → folder → file, with a coverage bar and covered / measured changed lines on each row. Single-child folders are joined into one row, the least-covered entries come first, and the top two levels start open. Bars are green from 80%, amber from 50%, red below.
If there is no change source, the panel says Nothing to judge yet with the reason; the rules are still saved and CI can call them.
Wire it into CI
Tabs for GitHub Actions, GitLab CI, Jenkins and Azure Pipelines, each a ready-to-paste step, and Copy. Every snippet calls the gate with the build's branch, the commit and the change's commits, keeps the JSON verdict, writes a Markdown summary (GitHub) or a JUnit file (the others), and fails the step only when .passed is false and the rule is blocking. Under the snippet: what branch, service, suite, format and sha do, and whether any rule has commit-status writing on.
How it works
Which rule judges a build
CI says what it is running for with branch, service and suite. Among the enabled rules whose scope covers them, the most specific wins: an exact branch scores 4, a branch with * scores 2, a service 2, a test plan 1. Ties go to the name that sorts first. A branch pattern takes one wildcard character, *; release/* matches release/4.2, and a pattern without * must match exactly. A rule scoped to a branch, service or test plan never matches a request that does not name one. When nothing matches, the project's KPI thresholds answer ("Project defaults"), and these are usually zero.
What is measured
- The change. The changed lines of the commits: either the commits CI sends (
shas), or every commit in the window (since, default 7 days for CI, 30 days on this screen). Changed lines are the new-side lines of each diff, mapped to coverage paths as on Impact. - The build. The run named by
run_key, else the latest run. Arun_keythat no run reported under is an error. A rule scoped to a service reads only that service's coverage reports. - Coverable lines. All reports of the run are merged per file: a line is covered if any report executed it. A changed line counts only if the run measured it as code. Comments, configuration and code that never loaded count neither for nor against.
- Changed-code coverage = covered ÷ coverable changed lines, one decimal. Overall coverage = covered ÷ measured lines of the whole run (or service).
The verdict
- Changed-code coverage is enforced when its threshold is above 0. A change with no coverable lines passes it, provided the run has coverage data.
- Overall coverage is enforced when its threshold is above 0 and either the matched rule sets it or CI asks with
enforce_overall. - No failing tests is enforced only when the rule asks for it; it fails if the run had any failed test.
- No tests without a result is enforced by the same switch; it fails if any test in the run has no result: its coverage arrived but no runner said whether it passed (a crashed runner, or no runner plugin). A test nobody vouched for is not a pass. Its value is that count, and
tests.noResultin the JSON carries it too. - Thresholds: a value CI sends (
min_changed,min_coverage) wins over the rule, which wins over the project's KPI thresholds. passedis what CI acts on. It is false when any enforced check fails, or when changed-code coverage is enforced and the run has no coverage data.statusis what a person reads:missing_datawhenever there is no run or the run measured nothing, even if nothing was enforced; otherwisepassedorfailed.- The breakdown returns at most 100 changed files, worst first.
The CI endpoint
GET /v1/agent/gate, authenticated with the agent token CI already holds. It always answers 200 with a verdict, so an HTTP error means CoverOps could not be reached. Parameters: branch, service, suite, shas (comma-separated, up to 500), since, until, run_key, min_changed, min_coverage, enforce_overall=true, sha, repository, target_url, and format:
- default: the JSON verdict;
format=markdown: a pull request comment with the verdict, a table of enforced checks, "N of M changed lines covered, across K commits", and up to 10 files under "Changed code nothing covered";format=junit: a JUnit file with one test case per enforced check; a failing check is a failing case with "value is below the required threshold".
When the matched rule has Write the verdict onto the commit on and the request carries sha, CoverOps posts a commit status with the token already connected for the repository: GitHub (including GitHub Enterprise), GitLab, Azure DevOps or Bitbucket Cloud. The context is coverops/ plus the rule name. An advisory rule that fails never posts a failure: on GitHub, GitLab and Bitbucket it posts a success whose description starts with "Advisory ·" and says what fell short, and on Azure DevOps it posts "not applicable". The status links to target_url, or to this screen when none is given. With several connected repositories, repository=<name> says which one. Posting never changes the verdict; its outcome comes back as status_post, with the context it was posted under when it went through.
Verdicts asked through this endpoint are also posted to the project's notification channels routed for quality-gate verdicts, except missing_data. A passing verdict goes only to channels that notify on recovery. Each notification links to this screen.
The CLI gate, the PR comment and its commit status
coverageops gate (also the GitHub Action with command: gate) asks the same endpoint and prints the verdict, the rule that judged it (blocking or advisory), the enforced checks, the least-covered changed files and the flows the change reaches. When the rule writes its verdict onto the commit, it also prints whether that worked and, if not, why.
- Flags:
--endpoint,--token,--base(envCOVERAGEOPS_BASE),--shas,--since,--run-key(envCOVERAGEOPS_RUN_KEY, else the CI build id),--min-changed,--min-coverage,--enforce-overall,--branch,--service,--suite,--sha,--repository,--repo,--github-token,--target-url,--comment,--pr. Endpoint and token fall back toCOVERAGEOPS_ENDPOINTandCOVERAGEOPS_TOKEN. - What the build is. The CLI sends the build's branch, service, test plan and head commit, so the narrowest rule covering them judges it:
- branch:
--branch, elseCOVERAGEOPS_BRANCH, else the CI's own variable (on a pull or merge request, its source branch, never the merge ref), else the git branch unless HEAD is detached; - service and test plan:
--service/--suite, elseCOVERAGEOPS_SERVICE/COVERAGEOPS_SUITE; sent only when set; - commit:
--sha, elseCOVERAGEOPS_COMMIT_SHA, else on a GitHubpull_requestrun the pull request's head, else the CI's commit variable, elseHEAD; - repository for the rule's commit status:
--repository(envCOVERAGEOPS_REPOSITORY), the name of a connected repository;--target-urlis the link that status carries.
- branch:
- The GitHub Action has
serviceandsuiteinputs for the same purpose; branch and commit are read from the workflow. - With
--base, the change is the commits from the merge base to the change's head, as in Test selection. - Exit code: 0 when
passed, and also when the build failed under an advisory rule (the CLI says the pipeline goes on); 1 when a blocking rule failed or had no coverage to judge; 2 when misconfigured or CoverOps cannot be reached. A verdict from the project defaults counts as blocking. - Commit status. With a GitHub token (
--github-tokenorGITHUB_TOKEN), a repository (--repoorGITHUB_REPOSITORY) and a commit, the CLI posts a GitHub status undercoverops/changed-code-coverage, and under the oldercoverlens/changed-code-coveragetoo unlessCOVERAGEOPS_STATUS_LEGACY=off. State: success when passed, and also for a failure under an advisory rule, whose description starts with "Advisory, not blocking ·"; otherwise error for missing data and failure for the rest. It goes to the same commit the CLI sends. - One status per verdict. When the rule that judged the build writes its verdict onto the commit, that status (
coverops/plus the rule name) is the verdict's only check: the CLI posts none of its own and prints the rule's context, which is the name branch protection should require. This holds even when the rule's post failed: the CLI prints why and does not stand in, because a stand-in under its own name would stay on the commit beside the rule's status once a re-run's post got through. Turning Write the verdict onto the commit on or off therefore changes the check's name; move the required check with it. - PR comment.
--comment(orCOVERAGEOPS_PR_COMMENT=true; Action inputcomment: true, which needspull-requests: write) writes one comment per pull request and rewrites it on every push. It holds the share of changed code that ran in tests, the enforced checks, a line saying the rule is advisory and does not block the merge when that applies, the flows the change reaches, a "Changed lines no test ran" table (up to 10 files), and, when tests failed, the count by cause (code change, test changed, environment, nothing it runs changed, never passed, flaky, quarantined, no comparison) with up to 10 tests and the suspect commit for each. The footer names the commit, the baseline and a link to the run page (COVERAGEOPS_DASHBOARD_URL, else the endpoint). It needs a GitHub token, the repository and a pull request number (--pr, else the Actions event). - The status and the comment never change the exit code.
What you can do
- New gate opens the editor:
- Name (required, unique in the project).
- Branch (default
*, suggestions from the branches your runs reported), Service (from your agents' services; blank measures the whole run), Test plan (from the suites that have reported; blank accepts any run). - Changed-code coverage (default 80%) and Overall coverage (default 0%), each 0–100.
- Fail when the measured run had failing tests (off by default). It also fails on tests with no result.
- Blocking — a failure fails the pipeline (off by default in the editor).
- Write the verdict onto the commit (off by default). The connected token needs permission to write statuses (GitHub
repo:status, GitLabapi). - A warning appears when another enabled rule has exactly the same scope. A rule that enforces nothing (both thresholds 0 and no test requirement) is refused.
- What does it say? evaluates that rule against the latest build in the verdict panel; Hide verdict goes back to automatic matching.
- Disable / Enable, Edit, Delete (with confirmation; builds in its scope fall through to a broader rule, or to none).
- Copy a CI snippet.
Changing rules needs write access to the project, and every create, edit and delete is recorded in the audit log.
Limits and good to know
- On this screen, automatic matching sends no branch, service or test plan, so only rules with branch
*and no service or test plan can match. Use What does it say? to see a scoped rule's verdict. - The CLI sends a service and a test plan only when you give them (flag, environment variable or Action input), so a rule scoped to a service or test plan applies to a CLI build only then.
- Azure DevOps commits carry no line numbers, so they add no coverable changed lines.
- Check labels inside the verdict (Changed-code coverage, Overall coverage, No failing tests) come from the server in English.
Related
- Impact
- Test selection
- Run detail
- Coverage monitoring
- Reports — KPI thresholds and notification channels
- Integrations
- Agents
- Audit log
- Concepts