From 6f46e7cdf10ab1a6c23e407abd565f3e0a125426 Mon Sep 17 00:00:00 2001 From: michelle-clayton-work Date: Mon, 1 Jun 2026 13:05:14 -0700 Subject: [PATCH] Use ONEESPT_BUILDTYPE for official vs unofficial detection The original Build.DefinitionName.EndsWith("(unofficial)") check is case-sensitive and depends on a human-set naming convention. A pipeline whose name does not end with exactly that literal suffix would be misclassified as official and retained forever. Switch to $env:ONEESPT_BUILDTYPE, which is set by 1ES Pipeline Templates and is already the source of truth used by docker-tools' validate-branch.yml and set-dry-run.yml for the same decision. Mirrors the equivalent fix already applied to microsoft/go-infra-images. --- eng/pipeline/steps/set-retain-build-var.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eng/pipeline/steps/set-retain-build-var.yml b/eng/pipeline/steps/set-retain-build-var.yml index ac415791..80bae15b 100644 --- a/eng/pipeline/steps/set-retain-build-var.yml +++ b/eng/pipeline/steps/set-retain-build-var.yml @@ -12,7 +12,12 @@ # of the configured official branches/prefixes. steps: - powershell: | - $isOfficialDefinition = -not "$(Build.DefinitionName)".EndsWith("(unofficial)") + # Use the 1ESPT-provided ONEESPT_BUILDTYPE env var as the source of truth + # for official vs unofficial, matching how docker-tools' validate-branch.yml + # and set-dry-run.yml decide. The Build.DefinitionName suffix convention is + # human-set and case-sensitive, so relying on it can permanently retain + # builds from an unofficial pipeline with a non-conforming name. + $isOfficialDefinition = "$env:ONEESPT_BUILDTYPE" -ne "Unofficial" $officialBranchList = "$(officialBranches)" $sourceBranch = "$(sourceBranch)" $officialBranchPrefixes = "$(officialBranchPrefixes)"