Arrays don't seem to be supported according to the documentation, but you can use a glob pattern.
artifacts:
reports:
cobertura: "**/build/cobertura.xml"
Thanks @sytech for the correct answer.
Gitlab 14.10 changed the config format for coverage reports: https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscoverage_report
This worked for me:
artifacts:
when: always
reports:
junit: junit.xml
coverage_report:
coverage_format: cobertura
path: packages/*/coverage/cobertura-coverage.xml
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
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.