Use pipeline System.AccessToken for Azure DevOps auth - #4
Open
tupe12334 wants to merge 1 commit into
Open
Conversation
PR #3 already added the shared comment.mjs module and the Azure DevOps adapter, but it authenticated only with a manually configured PAT (Basic auth) and left Azure DevOps usage undocumented. The issue asks for the pipeline-provided System.AccessToken to be used so users don't need to set up a PAT. - Default to Bearer auth using SYSTEM_ACCESSTOKEN (falls back to a manually configured PAT via AZURE_DEVOPS_TOKEN with Basic auth). - Derive the organization from the standard SYSTEM_COLLECTIONURI pipeline variable instead of requiring a custom one. - Add a README "Azure DevOps" section documenting the pipeline step, the required "Allow scripts to access the OAuth token" setting, and the env vars the adapter reads. Closes #1
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.
Summary
Issue #1 asked for Azure DevOps support, and PR #3 already merged the shared
src/comment.mjsmodule, thesrc/github/index.mjsadapter, and an initialsrc/azure/index.mjsadapter. That PR intentionally deferred one explicit part of the issue's ask:The existing adapter only supported a manually configured PAT via Basic auth — which doesn't work with the pipeline's OAuth token (
System.AccessTokenrequiresAuthorization: Bearer <token>, not Basic). This PR closes that gap:postWorkItemCommentnow takes anauthScheme("bearer"default, or"basic") and builds the rightAuthorizationheader for each.run()prefersSYSTEM_ACCESSTOKEN(mapped from$(System.AccessToken)) with Bearer auth, falling back to a manually configuredAZURE_DEVOPS_TOKENPAT with Basic auth only if the pipeline token isn't present.SYSTEM_COLLECTIONURIpipeline variable (withAZURE_DEVOPS_ORGas an override), instead of requiring a custom env var for something the pipeline already provides.No changes to the GitHub Actions path (
src/github/index.mjs,dist/index.mjs,action.yml) — verifieddist/is unchanged by the build.Test plan
pnpm test— all unit tests pass (including new coverage for Bearer vs Basic auth and org-from-URI parsing)pnpm lint— cleanpnpm build— regenerateddist/index.mjs, confirmed no diff (GitHub adapter untouched)Closes #1
This pull request was opened automatically by the "Open issues → fix PRs (owned repos + my orgs)" moadim routine.