Skip to content
This repository was archived by the owner on Jul 25, 2026. It is now read-only.

TriggerBuild V4: attribute triggered build to the original user via impersonation (ADO Server 2022.1+/2025) - #270

Open
eliorceva wants to merge 1 commit into
huserben:masterfrom
eliorceva:feature/impersonate-triggering-user
Open

TriggerBuild V4: attribute triggered build to the original user via impersonation (ADO Server 2022.1+/2025)#270
eliorceva wants to merge 1 commit into
huserben:masterfrom
eliorceva:feature/impersonate-triggering-user

Conversation

@eliorceva

Copy link
Copy Markdown

Since Azure DevOps Server 2022.1 Patch 1 (and 2025), the server ignores the
requestedFor field when queuing a build (security hardening), so "Queue Build
for user that triggered original build" no longer works — the triggered build is
always attributed to the authenticating identity. Fixes #263.

This restores it using the supported server-side impersonation mechanism:

  • Resolves the triggering user's legacy IdentityDescriptor from
    BUILD_REQUESTEDFORID / RELEASE_REQUESTEDFORID via the Identities API.
  • Sends it in the X-TFS-Impersonate header, scoped to the queue call only
    (condition checks / waiting stay as the authenticating identity).
  • Requires the authenticating identity to hold the collection permission
    "Make requests on behalf of others".

Safe fallback: if the descriptor can't be resolved or impersonation isn't
available (e.g. Azure DevOps Services), it logs a warning and falls back to the
previous behaviour — no hard failure.

Adds unit tests for descriptor resolution, header injection scoped to the queue
call, and the fallback path. Verified live on Azure DevOps Server 2025.

…mpersonation

Since Azure DevOps Server 2022.1 Patch 1 (and 2025), the server ignores the
`requestedFor` field when queuing a build for security reasons, so the
"Queue Build for user that triggered original build" option no longer works -
the triggered build is always attributed to the authenticating identity
(e.g. Project Collection Build Service). See issue huserben#263.

This restores the behaviour using the supported server-side impersonation
mechanism:
- Resolve the triggering user's legacy IdentityDescriptor from BUILD_REQUESTEDFORID
  (or RELEASE_REQUESTEDFORID) via the Identities API.
- Send it in the `X-TFS-Impersonate` header on the queue request, scoped to the
  queue call only (condition checks and build-waiting keep running as the
  authenticating identity).
- Requires the authenticating identity to hold the collection permission
  "Make requests on behalf of others".

The change is non-fatal: if the descriptor can't be resolved or the connection
can't be reached, it logs a warning and falls back to the previous behaviour, so
it is safe where impersonation is unavailable (e.g. Azure DevOps Services).

Adds unit tests covering descriptor resolution, header injection scoped to the
queue call, and the graceful-fallback path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@huserben

Copy link
Copy Markdown
Owner

Hi @eliorceva

Thanks for your PR, however, I'm not actively maintaining the task anymore. So while I could merge it, properly testing it would take time I don't have (apart from the fact that I'm not using an ADO environment anymore which complicates it even more), and I will not publish it untested.

There may be forks of this tasks or other tasks that achieve the same thing already. My proposal is that you check those out, or, if you want, create your own fork and use this one.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Queue Build for user that triggered original build Option superseded by Personal Access Token User

2 participants