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
Conversation
…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>
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. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Since Azure DevOps Server 2022.1 Patch 1 (and 2025), the server ignores the
requestedForfield when queuing a build (security hardening), so "Queue Buildfor 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:
BUILD_REQUESTEDFORID / RELEASE_REQUESTEDFORID via the Identities API.
X-TFS-Impersonateheader, scoped to the queue call only(condition checks / waiting stay as the authenticating identity).
"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.