From f49f8116ce989dcb751f19d7a7f0e3f185b3b90e Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Tue, 28 Jul 2026 15:03:31 +0800 Subject: [PATCH] ci: run npm through script steps instead of the Npm@1 task The Npm@1 task generates its own .npmrc and points npm at it through npm_config_userconfig, which discards the CFS credential that NpmAuthenticate@0 writes into $(Agent.TempDirectory)/.npmrc. The CFS registry still applies, because it is supplied through the npm_config_registry environment variable and an environment variable outranks every npm config file. The task therefore requests packages from the CFS feed with no token: registry = https://pkgs.dev.azure.com/mseng/VSJava/_packaging/vscjava/npm/registry/ userconfig = /mnt/vss/_work/1/npm/.npmrc npm error code E401 npm error Unable to authenticate, your authentication token seems to be invalid. A plain script step inherits both values from the job environment, so the credential survives. Steps that do not restore packages are converted as well, so that a single mechanism applies throughout and no step is left pointing at the CFS feed unauthenticated. Display names, working directories, and the enabled and verbose flags are preserved. --- .azure-pipelines/ci.yml | 10 ++-------- .azure-pipelines/nightly.yml | 4 +--- .azure-pipelines/rc.yml | 4 +--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/ci.yml b/.azure-pipelines/ci.yml index ba0d707d..15fbc937 100644 --- a/.azure-pipelines/ci.yml +++ b/.azure-pipelines/ci.yml @@ -55,16 +55,10 @@ extends: inputs: versionSpec: 20.x - template: /.azure-pipelines/npm-cfs.yml@self - - task: Npm@1 + - script: npm install --verbose displayName: npm install - inputs: - verbose: true - - task: Npm@1 + - script: npm run build-server displayName: npm run build-server - inputs: - command: custom - verbose: false - customCommand: run build-server - task: Bash@3 displayName: vsce package inputs: diff --git a/.azure-pipelines/nightly.yml b/.azure-pipelines/nightly.yml index 6b8ce9f2..d7e8461f 100644 --- a/.azure-pipelines/nightly.yml +++ b/.azure-pipelines/nightly.yml @@ -69,10 +69,8 @@ extends: - script: java --version displayName: 'Check Java installation' - template: /.azure-pipelines/npm-cfs.yml@self - - task: Npm@1 + - script: npm install displayName: npm install - inputs: - verbose: false - task: CmdLine@2 displayName: npx gulp build_server inputs: diff --git a/.azure-pipelines/rc.yml b/.azure-pipelines/rc.yml index eefd22d1..00e1bb62 100644 --- a/.azure-pipelines/rc.yml +++ b/.azure-pipelines/rc.yml @@ -64,10 +64,8 @@ extends: - script: java --version displayName: 'Check Java installation' - template: /.azure-pipelines/npm-cfs.yml@self - - task: Npm@1 + - script: npm install displayName: npm install - inputs: - verbose: false - task: CmdLine@2 displayName: npx gulp build_server inputs: