Skip to content

[AzureDevops] Make the build badge send the PAT so it works on private projects#11945

Open
azizu06 wants to merge 2 commits into
badges:masterfrom
azizu06:fix-issue-10162
Open

[AzureDevops] Make the build badge send the PAT so it works on private projects#11945
azizu06 wants to merge 2 commits into
badges:masterfrom
azizu06:fix-issue-10162

Conversation

@azizu06

@azizu06 azizu06 commented Jun 21, 2026

Copy link
Copy Markdown

Closes #10162.

The Azure DevOps build badge was the only Azure DevOps badge that didn't send the user's PAT, so it broke on private projects. It extended BaseSvgScrapingService (the anonymous status-image scraper) instead of AzureDevOpsBase (the authenticated JSON API) like the coverage, tests and release badges.

Fix

It now extends AzureDevOpsBase and reads the latest completed build from /_apis/build/builds, mapping the result onto the existing build-status output.

stage / job

To keep ?stage= and ?job= working I read the build's Timeline (/_apis/build/builds/{id}/timeline) and pull the matching record's result. Two quirks from the real API: the Timeline endpoint rejects the api-version the other endpoints use (call it without one), and it reports succeededWithIssues/skipped, which I've mapped onto the existing statuses.

One behavior change to flag

The old status image could tell "definition not found" apart from "user or project not found". The JSON API 302-redirects anything it can't reach anonymously, so the response can't distinguish them. I consolidated both into "user or project not found", matching the coverage and tests badges. Happy to change this if you'd prefer.

Tests

Added azure-devops-build.spec.js (the badge had no unit spec) asserting the PAT is sent, plus mocked service tests for the stage/job logic, including one where the build succeeded but the requested stage failed. Replaced two old image-endpoint live tests with a mocked 404. All green locally, siblings unaffected.

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 ✨ Thanks for your contribution to Shields, @azizu06!

Generated by 🚫 dangerJS against 094a156

@PyvesB

PyvesB commented Jun 21, 2026

Copy link
Copy Markdown
Member

Hello @azizu06 👋🏻

I've not yet looked throught the changes in details, but the AI files will probably have to go!

@azizu06

azizu06 commented Jun 21, 2026

Copy link
Copy Markdown
Author

Hello @azizu06 👋🏻

I've not yet looked throught the changes in details, but the AI files will probably have to go!

Sorry about that, forgot to remove the temp files I had for planning.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Azure DevOps - Build Badge - PAT Token not used on private projects

2 participants