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-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 }} 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: