Skip to content

GitLab CI Kotlin DSLopensavvy.gitlab.ciArtifactscoverage

coverage

fun coverage(format: String, path: String)

Collects code coverage reports in Cobertura or JaCoCo formats.

The coverage report is uploaded to GitLab as an artifact. You can generate multiple JaCoCo or Cobertura reports and include them using wildcards - the results are aggregated in the final coverage report. The results appear in merge request diff annotations.

Coverage reports from child pipelines appear in merge request diff annotations, but the artifacts themselves are not shared with parent pipelines.

Example

val test by job {
    script {
        shell("./gradlew test jacocoTestReport")
    }

    artifacts {
        coverage("cobertura", "build/reports/jacoco/test/jacocoTestReport.xml")
    }
}

Example: JaCoCo format with wildcards

artifacts {
    coverage("jacoco", "target/site/jacoco/jacoco*.xml")
}

External resources