From 8c865a05e2794088e13eb526444613d793588856 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Fri, 6 Mar 2026 23:57:08 -0800 Subject: [PATCH 1/2] Use create-authenticated-npmrc.yml for all npmrc authentication --- .../pipelines/templates/jobs/npm-publish.yml | 16 ++++++---------- .../steps/create-tags-and-git-release.yml | 3 +++ .../templates/steps/update-docsms-metadata.yml | 6 ++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/eng/common/pipelines/templates/jobs/npm-publish.yml b/eng/common/pipelines/templates/jobs/npm-publish.yml index e435a213c9eb..f3b91bcd0119 100644 --- a/eng/common/pipelines/templates/jobs/npm-publish.yml +++ b/eng/common/pipelines/templates/jobs/npm-publish.yml @@ -68,11 +68,13 @@ jobs: Write-Host "Publishing packages with tag: $tag" displayName: 'Packages to be published' + - template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml + parameters: + npmrcPath: $(ArtifactPath)/.npmrc + registryUrl: ${{ parameters.Registry }} + CustomCondition: and(succeeded(), ne(variables['SkipPublishing'], 'true')) + - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: - - - template: /eng/common/pipelines/templates/steps/reset-npmrc.yml - parameters: - Registry: ${{ parameters.Registry }} - task: EsrpRelease@9 displayName: 'Publish ${{ parameters.ArtifactName }} via ESRP' @@ -117,12 +119,6 @@ jobs: condition: and(succeeded(), ne(variables['SkipPublishing'], 'true')) - ${{ else }}: - - template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml - parameters: - npmrcPath: $(ArtifactPath)/.npmrc - registryUrl: ${{ parameters.Registry }} - CustomCondition: and(succeeded(), ne(variables['SkipPublishing'], 'true')) - - pwsh: | foreach ($package in (dir $(ArtifactPath) *.tgz -Recurse)) { Write-Host "npm publish $package --verbose --access public --tag $(TagName) --registry ${{ parameters.Registry }}" diff --git a/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml b/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml index ed7c2e420208..28a5bf7fac61 100644 --- a/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml +++ b/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml @@ -6,6 +6,7 @@ parameters: RepoId: $(Build.Repository.Name) WorkingDirectory: '' ScriptDirectory: eng/common/scripts + NpmConfigUserConfig: '' steps: - task: PowerShell@2 @@ -23,3 +24,5 @@ steps: timeoutInMinutes: 5 env: GH_TOKEN: $(azuresdk-github-pat) + ${{ if ne(parameters.NpmConfigUserConfig, '') }}: + NPM_CONFIG_USERCONFIG: ${{ parameters.NpmConfigUserConfig }} diff --git a/eng/common/pipelines/templates/steps/update-docsms-metadata.yml b/eng/common/pipelines/templates/steps/update-docsms-metadata.yml index 51edbc44b2f3..9b4f9e33b67c 100644 --- a/eng/common/pipelines/templates/steps/update-docsms-metadata.yml +++ b/eng/common/pipelines/templates/steps/update-docsms-metadata.yml @@ -29,6 +29,9 @@ parameters: - name: PackageSourceOverride type: string default: '' + - name: NpmConfigUserConfig + type: string + default: '' steps: - ${{ if eq(length(parameters.PackageInfoLocations), 0) }}: - pwsh: | @@ -91,6 +94,9 @@ steps: -RepoId '${{ parameters.RepoId }}' ` -PackageSourceOverride '${{ parameters.PackageSourceOverride }}' displayName: Apply Documentation Updates + env: + ${{ if ne(parameters.NpmConfigUserConfig, '') }}: + NPM_CONFIG_USERCONFIG: ${{ parameters.NpmConfigUserConfig }} - template: /eng/common/pipelines/templates/steps/git-push-changes.yml parameters: From 4b0057e7bd07bacf8b12d58d8ca85d09c3763044 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Sat, 7 Mar 2026 00:47:27 -0800 Subject: [PATCH 2/2] Add option to skip npmrc authentication --- .../steps/create-authenticated-npmrc.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml b/eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml index cb29d1312ebd..1b67a893874f 100644 --- a/eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml +++ b/eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml @@ -9,6 +9,9 @@ parameters: - name: ServiceConnection type: string default: '' + - name: SkipAuthentication + type: boolean + default: false steps: - pwsh: | @@ -25,9 +28,10 @@ steps: displayName: 'Create .npmrc' condition: ${{ parameters.CustomCondition }} -- task: npmAuthenticate@0 - displayName: Authenticate .npmrc - condition: ${{ parameters.CustomCondition }} - inputs: - workingFile: ${{ parameters.npmrcPath }} - azureDevOpsServiceConnection: ${{ parameters.ServiceConnection }} +- ${{ if not(parameters.SkipAuthentication) }}: + - task: npmAuthenticate@0 + displayName: Authenticate .npmrc + condition: ${{ parameters.CustomCondition }} + inputs: + workingFile: ${{ parameters.npmrcPath }} + azureDevOpsServiceConnection: ${{ parameters.ServiceConnection }}