[AzureDevops] Make the build badge send the PAT so it works on private projects#11945
Open
azizu06 wants to merge 2 commits into
Open
[AzureDevops] Make the build badge send the PAT so it works on private projects#11945azizu06 wants to merge 2 commits into
azizu06 wants to merge 2 commits into
Conversation
Contributor
Member
|
Hello @azizu06 👋🏻 I've not yet looked throught the changes in details, but the AI files will probably have to go! |
Author
Sorry about that, forgot to remove the temp files I had for planning. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ofAzureDevOpsBase(the authenticated JSON API) like the coverage, tests and release badges.Fix
It now extends
AzureDevOpsBaseand 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 theapi-versionthe other endpoints use (call it without one), and it reportssucceededWithIssues/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.