From 19d93584bed946a4d91d1c66fa2350d475556800 Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Fri, 6 Mar 2026 18:21:51 +0100 Subject: [PATCH] Scope npm user-config override to plugin build step Replace the npmAuthenticate@0 tasks and .npmrc deletion with a scoped NPM_CONFIG_USERCONFIG env var on just the Build Azure DevOps plugin step. This points npm at a non-existent user config file so it ignores stale credentials from C:\Users\cloudtest\.npmrc without affecting other jobs on shared agents. Verified locally: npm skips the user config section entirely when NPM_CONFIG_USERCONFIG points to a non-existent path, while still reading the project-level .npmrc for the registry URL. Fixes #7365 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/pipelines/templates/BuildAndTest.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 98401edb18c..f8309057b92 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -167,19 +167,16 @@ steps: $(_OfficialBuildIdArgs) displayName: Pack docs transport package - - task: npmAuthenticate@0 - inputs: - workingFile: $(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/.npmrc - displayName: Authenticate npm for Azure DevOps plugin (root) - - - task: npmAuthenticate@0 - inputs: - workingFile: $(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/azure-devops-report/tasks/PublishAIEvaluationReport/.npmrc - displayName: Authenticate npm for Azure DevOps plugin (task) - - pwsh: | $(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/azure-devops-report/build.ps1 -OutputPath $(Build.Arcade.VSIXOutputPath) displayName: Build Azure DevOps plugin + env: + # Some CI agents have stale npm auth tokens in the user-level .npmrc + # (e.g. C:\Users\cloudtest\.npmrc). npm sends these stale credentials + # to the public dotnet-public-npm feed, causing E401 errors. Override + # the user config path to a non-existent file so npm ignores stale + # credentials and uses anonymous access for the public feed. + NPM_CONFIG_USERCONFIG: $(Agent.TempDirectory)/.npmrc-not-exists - script: ${{ parameters.buildScript }} -restore