From 9ef7fa706bb67599dc625e14411ac4d59a2f5024 Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Tue, 28 Jul 2026 15:03:36 +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/vscode-java-test-ci.yml | 22 ++++--------------- .azure-pipelines/vscode-java-test-nightly.yml | 16 +++----------- .azure-pipelines/vscode-java-test-rc.yml | 16 +++----------- 3 files changed, 10 insertions(+), 44 deletions(-) diff --git a/.azure-pipelines/vscode-java-test-ci.yml b/.azure-pipelines/vscode-java-test-ci.yml index 828ad376..43dfecc4 100644 --- a/.azure-pipelines/vscode-java-test-ci.yml +++ b/.azure-pipelines/vscode-java-test-ci.yml @@ -51,28 +51,14 @@ extends: jdkArchitectureOption: x64 jdkSourceOption: PreInstalled - template: /.azure-pipelines/npm-cfs.yml@self - - task: Npm@1 + - script: npm install displayName: npm install - inputs: - verbose: false - - task: Npm@1 + - script: npm run lint displayName: npm run lint - inputs: - command: custom - verbose: false - customCommand: run lint - - task: Npm@1 + - script: npm run build-plugin displayName: npm run build-plugin - inputs: - command: custom - verbose: false - customCommand: run build-plugin - - task: Npm@1 + - script: npm run vscode:prepublish displayName: npm run vscode:prepublish - inputs: - command: custom - verbose: false - customCommand: run vscode:prepublish - task: Bash@3 displayName: vsce package inputs: diff --git a/.azure-pipelines/vscode-java-test-nightly.yml b/.azure-pipelines/vscode-java-test-nightly.yml index 886a7302..3447b56d 100644 --- a/.azure-pipelines/vscode-java-test-nightly.yml +++ b/.azure-pipelines/vscode-java-test-nightly.yml @@ -67,22 +67,12 @@ 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: Npm@1 + - script: npm run lint displayName: npm run lint - inputs: - command: custom - verbose: false - customCommand: run lint - - task: Npm@1 + - script: npm run build-plugin displayName: npm run build-plugin - inputs: - command: custom - verbose: false - customCommand: run build-plugin - task: PowerShell@2 displayName: Sign Jars env: diff --git a/.azure-pipelines/vscode-java-test-rc.yml b/.azure-pipelines/vscode-java-test-rc.yml index 7f1a00da..04e8fe84 100644 --- a/.azure-pipelines/vscode-java-test-rc.yml +++ b/.azure-pipelines/vscode-java-test-rc.yml @@ -62,22 +62,12 @@ 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: Npm@1 + - script: npm run lint displayName: npm run lint - inputs: - command: custom - verbose: false - customCommand: run lint - - task: Npm@1 + - script: npm run build-plugin displayName: npm run build-plugin - inputs: - command: custom - verbose: false - customCommand: run build-plugin - task: PowerShell@2 displayName: Sign Jars env: