🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › testing › code coverage › coverage visualization › cobertura
Cobertura coverage visualization | GitLab Docs
The following .gitlab-ci.yml example uses pytest-cov to collect test coverage data: run tests: stage: test image: python:3 script: - pip install pytest pytest-cov - pytest --cov --cov-report term --cov-report xml:coverage.xml artifacts: reports: coverage_report: coverage_format: cobertura path: coverage.xml
🌐
Medium
medium.com › @hax.artisan › gitlab-code-coverage-visualization-with-cobertura-9cbf3df8b196
GitLab code coverage visualization with Cobertura | by MingSheng | Medium
September 6, 2024 - GitLab consumes coverage report with artifcats keyword where cobertura xml is shared · artifacts: reports: coverage_report: coverage_format: cobertura path: cobertura.xml
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › testing › code coverage
Code coverage | GitLab Docs
Coverage reporting extracts a percentage from your test tool’s job log output. You define a regular expression in the coverage keyword. GitLab scans the job log, extracts the first matching number, and stores it.
🌐
GitLab
docs.gitlab.com › ee › ci › testing › test_coverage_visualization.html
Test coverage visualization
Sign in to GitLab · By signing in you accept the Terms of Use and acknowledge the Privacy Statement and Cookie Policy · Don't have an account yet? Register now · or sign in with · Remember me · Explore Help About GitLab GitLab community forum · English · 简体中文 · 日本語
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › testing › code coverage › coverage visualization
Coverage visualization | GitLab Docs
test: script: - run tests with coverage artifacts: reports: coverage_report: coverage_format: cobertura # or jacoco path: coverage/coverage.xml ... To collect multiple reports, use a wildcard in the artifact path. GitLab merges the results into a single report.
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › ci/cd yaml syntax reference › artifacts reports
CI/CD artifacts reports types | GitLab Docs
After the pipeline completes, GitLab parses the report and displays line-by-line coverage annotations in the merge request diff. This keyword produces diff annotations only. It does not display a coverage percentage in the MR widget or populate coverage history graphs. To display a coverage percentage, configure the coverage keyword separately. ... artifacts: reports: coverage_report: coverage_format: cobertura path: coverage/cobertura-coverage.xml
🌐
GitHub
gist.github.com › rishitells › 3c4536131819cff4eba2c8ab5bbb4570
Setting up Jest tests and coverage in GitLab CI · GitHub
You can specify one or more coverage reports to collect, including wildcard paths. GitLab then takes the coverage information in all the files and combines it together. For the coverage analysis to work, you have to provide a properly formatted Cobertura XML report to artifacts:reports:cobertura.
🌐
GitHub
github.com › diffblue › gitlab › blob › master › doc › ci › testing › test_coverage_visualization.md
gitlab/doc/ci/testing/test_coverage_visualization.md at master · diffblue/gitlab
The following .gitlab-ci.yml example for Java or Kotlin uses Gradle to build the project and JaCoCo coverage-tooling to generate the coverage artifact. You can check the Docker image configuration and scripts if you want to build your own image. GitLab expects the artifact in the Cobertura format, so you have to execute a few scripts before uploading it.
Author: diffblue
Find elsewhere
🌐
KodeKloud Notes
notes.kodekloud.com › continuous integration with gitlab › pipeline configure coverage and archive reports
Pipeline Configure Coverage and Archive Reports - KodeKloud
January 28, 2026 - artifacts: reports: coverage_report: coverage_format: cobertura path: coverage/cobertura-coverage.xml · GitLab can parse test logs and extract a coverage percentage using a regular expression.
🌐
Kluster
kluster.ai › blog › code-coverage-gitlab
code coverage gitlab: Master GitLab Metrics
November 29, 2025 - pytest --cov --cov-report=xml artifacts: reports: coverage_report: coverage_format: cobertura path: coverage.xml · With this in place, GitLab doesn't just know the final percentage; it can show you red and green indicators directly in the file diffs.
🌐
DEV Community
dev.to › lazypro › gitlab-ci-for-node-testing-and-coverage-2ik3
Gitlab CI for Node Testing and Coverage - DEV Community
June 6, 2022 - The full .gitlab-ci.yml, which includes all mentioned features, is as follows. test_ci: script: - npm run test artifacts: paths: - coverage/ reports: junit: - test-results.xml coverage_report: coverage_format: cobertura path: coverage/cobertura-coverage.xml coverage: '/All files\s+\|\s+\d+\.\d+/'
🌐
GitLab
docs.gitlab.com › gitlab docs › use gitlab › use ci/cd to build your application › testing › code coverage › coverage visualization › jacoco
JaCoCo coverage visualization | GitLab Docs
test-jdk11: stage: test image: maven:3.6.3-jdk-11 script: - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report artifacts: reports: coverage_report: coverage_format: jacoco path: target/site/jacoco/jacoco.xml · Set path to the location of the generated JaCoCo XML report. If the job generates multiple reports, use a wildcard in the artifact path. JaCoCo visualization uses instructions (C0 Coverage), represented as ci (covered instructions) in reports.
🌐
GitLab
docs.gitlab.com › ee › ci › testing › test_coverage_visualization › cobertura.html
Cobertura Coverage Reports
They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, enabling you to securely log into the site, filling in forms, or using the customer checkout. GitLab processes any personal data collected through these cookies on the basis of our legitimate interest.
🌐
Aldec
aldec.com › support › resources › documentation › application notes › code coverage visualization in gitlab
Code Coverage Visualization in GitLab - Application Notes - Documentation - Resources - Support - Aldec
For example, with the help of GitLab ... will allow you to see which lines are covered by tests, and which lines still require coverage before the MR is merged. GitLab requires Cobertura format as input to be able to generate code coverage analysis reports....
🌐
Smhk
smhk.net › note › 2023 › 08 › gitlab-enable-coverage-reporting-with-pytest
GitLab: Enable coverage reporting with pytest - smhk
Then, in .gitlab-ci.yml, use the coverage_report field with the following configuration to get GitLab to extract the coverage: ... unit_test:py310: stage: test artifacts: reports: coverage_report: coverage_format: cobertura path: 'coverage/py310/coverage.xml' coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
🌐
GitLab
forum.gitlab.com › gitlab ci/cd
Demystifying Coverage and cobertura.xml - GitLab CI/CD - GitLab Forum
February 22, 2024 - I’ve been struggling for a while with trying to get coverage to show up. (We are running 16.8 / Premium) I’m using golang Here is my XML file after a variety of sed commands
Top answer
1 of 2
3

You must add coverage keyword to your .gitlab-ci.yml See: https://docs.gitlab.com/ee/ci/testing/code_coverage/index.html

You can calculate coverage from the output

...
script:
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' target/site/jacoco/jacoco.csv
  coverage: '/\d+\.\d+.%.covered/'
...

Example

clean-test-jacoco:
  image: maven:latest
  stage: test
  script:
    - mvn $MAVEN_CLI_OPTS clean verify
    - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' target/site/jacoco/jacoco.csv
  coverage: '/\d+\.\d+.%.covered/'
  artifacts:
    paths:
      - target/site/jacoco/jacoco.xml
    reports:  
      coverage_report:
        coverage_format: jacoco
        path: target/site/jacoco/jacoco.xml

Also you can create a badge

!coverage
2 of 2
2

You should see them in the Tests tab on the Pipelines :

https://gitlab.com/{group}/{project}/-/pipelines/{pipeline_id}/test_report

Example :

You also have access to the report on the Merge Request if you have one open :

To see the coverage you need to configure the coverage keyword in the job :

coverage:
  script:
    - mvn clean install surefire-report:report
  image: maven:3.9.9-sapmachine-23
  stage: coverage
  coverage: /Total.*?([0-9]{1,3})%/
  artifacts:
    [...]

This will tell to Gitlab the regex to use to get the coverage based on your coverage tool, here Jacoco. Based on the documentation :

After a pipeline runs successfully, you can view code coverage results in:

  • Merge request widget: See the coverage percentage and changes compared to the target branch.

  • Merge request widget showing code coverage percentage

  • Merge request diff: Review which lines are covered by tests. Available with Cobertura and JaCoCo reports. Pipeline jobs: Monitor coverage results for individual jobs.

🌐
GitLab
gitlab.com › gitlab.org › #344533
New `coverage_report` keyword (#344533) · Issues · GitLab.org / GitLab · GitLab
November 1, 2021 - Problem to solve cobertura.xml is a legacy format for testing reports. As users are leveraging other types of coverage reports we...