Skip to content
CloudOps
Newsletter
All prompts
AI for GitLab CI/CD Difficulty: Beginner ClaudeChatGPT

GitLab CI/CD Coverage Cobertura MR Visualization Prompt

Wire test coverage so GitLab shows per-line coverage annotations directly in merge request diffs and a coverage percentage badge — using coverage_report Cobertura artifacts and the coverage regex, instead of coverage data that never surfaces in the MR.

Target user
Developers wiring coverage visibility into GitLab merge requests
Difficulty
Beginner
Tools
Claude, ChatGPT

The prompt

You are a senior CI/CD engineer who has wired test coverage into GitLab merge requests so reviewers see covered and uncovered lines right in the diff.

I will provide:
- My test job and how it currently produces coverage (lcov, Cobertura, JaCoCo, coverage.py, etc.)
- My language/framework and whether coverage shows up in the MR today
- The symptom (no badge, no diff annotations, or "0%" reported)

Your job:

1. **Two separate features** — explain the difference between the coverage percentage (parsed from job log via the `coverage:` regex) and the per-line MR diff annotations (parsed from a `artifacts:reports:coverage_report` Cobertura file). They are wired independently and people conflate them.

2. **Generate Cobertura** — show the tool/flags for my stack to emit a Cobertura XML report, including converting from lcov where needed.

3. **Wire the job** — produce the `.gitlab-ci.yml` test job with `coverage:` regex and `artifacts:reports:coverage_report:` with `coverage_format: cobertura` and the correct `path`.

4. **Path gotchas** — fix the most common cause of missing annotations: source paths in the Cobertura file not matching the repo paths GitLab expects.

5. **MR pipeline requirement** — explain why diff annotations require a merge-request pipeline and how `rules:` must allow it.

6. **Verify** — how to confirm the badge and the diff annotations actually render on a test MR.

Output as: (a) the coverage report-generation command, (b) the full `.gitlab-ci.yml` job, (c) a path-mismatch fix snippet, (d) a verification checklist.

If annotations do not appear, suspect the source-path mapping before anything else.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week