Skip to content

Use pipeline System.AccessToken for Azure DevOps auth - #4

Open
tupe12334 wants to merge 1 commit into
mainfrom
feat/issue-1-azure-devops-support
Open

Use pipeline System.AccessToken for Azure DevOps auth#4
tupe12334 wants to merge 1 commit into
mainfrom
feat/issue-1-azure-devops-support

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Summary

Issue #1 asked for Azure DevOps support, and PR #3 already merged the shared src/comment.mjs module, the src/github/index.mjs adapter, and an initial src/azure/index.mjs adapter. That PR intentionally deferred one explicit part of the issue's ask:

using an ADO personal access token or pipeline OAuth token for auth (System.AccessToken predefined variable is the standard pipeline-provided token — use that, don't require a manual PAT setup if avoidable)

The existing adapter only supported a manually configured PAT via Basic auth — which doesn't work with the pipeline's OAuth token (System.AccessToken requires Authorization: Bearer <token>, not Basic). This PR closes that gap:

  • postWorkItemComment now takes an authScheme ("bearer" default, or "basic") and builds the right Authorization header for each.
  • run() prefers SYSTEM_ACCESSTOKEN (mapped from $(System.AccessToken)) with Bearer auth, falling back to a manually configured AZURE_DEVOPS_TOKEN PAT with Basic auth only if the pipeline token isn't present.
  • The organization is now derived from the standard SYSTEM_COLLECTIONURI pipeline variable (with AZURE_DEVOPS_ORG as an override), instead of requiring a custom env var for something the pipeline already provides.
  • Added a README "Azure DevOps" section documenting the pipeline step, the required "Allow scripts to access the OAuth token" setting, and every env var the adapter reads.

No changes to the GitHub Actions path (src/github/index.mjs, dist/index.mjs, action.yml) — verified dist/ 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 — clean
  • pnpm build — regenerated dist/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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Azure DevOps support with shared core comment logic

1 participant