Skip to content

[TeamCity] Add 'metric' query parameter to TeamCity coverage badge - #12147

Open
Filipot2 wants to merge 2 commits into
badges:masterfrom
Filipot2:feature/teamcity-coverage-metric
Open

Filipot2 wants to merge 2 commits into
badges:masterfrom
Filipot2:feature/teamcity-coverage-metric

Conversation

@Filipot2

@Filipot2 Filipot2 commented Sep 3, 2026

Copy link
Copy Markdown

Added a new metric query parameter to the TeamCity coverage badge to allow users to specify which coverage type to display (e.g., line, block, method, class, branch).

  • Kept backward compatibility by setting the default metric to statement (which maps to S), so existing badge URLs will not break.
  • The metric codes (S, L, M, C, B, R) map directly to TeamCity's internal CodeCoverageAbs* statistical values. Reference: TeamCity Custom Chart Documentation.

Testing & Mocking Details:
I was unable to test against the live JetBrains TeamCity server (https://teamcity.jetbrains.com) because it now requires authentication to view statistics for the FileHelpersStable build (it returns a 401 Unauthorized / inaccessible error for guests).

Because I couldn't hit the actual API, I tested this logic entirely via the local mocked service tests in teamcity-coverage.tester.js. The tests intercept the outbound request and feed it mocked JSON responses to prove that the code correctly extracts the different metric values (like CodeCoverageAbsLCovered) and calculates the percentage accurately without needing a live, public TeamCity server.

Closes #<#3111>

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
Messages
πŸ“– ✨ Thanks for your contribution to Shields, @Filipot2!

Generated by 🚫 dangerJS against 963d7ea

@PyvesB

PyvesB commented Sep 12, 2026

Copy link
Copy Markdown
Member

I was unable to test against the live JetBrains TeamCity server (https://teamcity.jetbrains.com) because it now requires authentication to view statistics for the FileHelpersStable build (it returns a 401 Unauthorized / inaccessible error for guests).
Because I couldn't hit the actual API, I tested this logic entirely via the local mocked service tests in teamcity-coverage.tester.js. The tests intercept the outbound request and feed it mocked JSON responses to prove that the code correctly extracts the different metric values (like CodeCoverageAbsLCovered) and calculates the percentage accurately without needing a live, public TeamCity server.

We do have credentials configured in our CI and in production, but you won't have access to them through a fork (#8820). Did you try generating your own credentials and running the live test locally?

@Filipot2

Copy link
Copy Markdown
Author

I did not, I was not aware something like that was possible. Let me check that and get back to you here

@PyvesB PyvesB added the service-badge New or updated service badge label Sep 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

service-badge New or updated service badge

Development

Successfully merging this pull request may close these issues.

2 participants