Skip to content

Commit b494ea5

Browse files
Sync eng/common directory with azure-sdk-tools for PR 14405 (#45568)
* Use create-authenticated-npmrc.yml for all npmrc authentication * Add option to skip npmrc authentication --------- Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
1 parent 2117dfb commit b494ea5

4 files changed

Lines changed: 25 additions & 16 deletions

File tree

eng/common/pipelines/templates/jobs/npm-publish.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ jobs:
6868
Write-Host "Publishing packages with tag: $tag"
6969
displayName: 'Packages to be published'
7070
71+
- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml
72+
parameters:
73+
npmrcPath: $(ArtifactPath)/.npmrc
74+
registryUrl: ${{ parameters.Registry }}
75+
CustomCondition: and(succeeded(), ne(variables['SkipPublishing'], 'true'))
76+
7177
- ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}:
72-
73-
- template: /eng/common/pipelines/templates/steps/reset-npmrc.yml
74-
parameters:
75-
Registry: ${{ parameters.Registry }}
7678

7779
- task: EsrpRelease@9
7880
displayName: 'Publish ${{ parameters.ArtifactName }} via ESRP'
@@ -117,12 +119,6 @@ jobs:
117119
condition: and(succeeded(), ne(variables['SkipPublishing'], 'true'))
118120
119121
- ${{ else }}:
120-
- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml
121-
parameters:
122-
npmrcPath: $(ArtifactPath)/.npmrc
123-
registryUrl: ${{ parameters.Registry }}
124-
CustomCondition: and(succeeded(), ne(variables['SkipPublishing'], 'true'))
125-
126122
- pwsh: |
127123
foreach ($package in (dir $(ArtifactPath) *.tgz -Recurse)) {
128124
Write-Host "npm publish $package --verbose --access public --tag $(TagName) --registry ${{ parameters.Registry }}"

eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ parameters:
99
- name: ServiceConnection
1010
type: string
1111
default: ''
12+
- name: SkipAuthentication
13+
type: boolean
14+
default: false
1215

1316
steps:
1417
- pwsh: |
@@ -25,9 +28,10 @@ steps:
2528
displayName: 'Create .npmrc'
2629
condition: ${{ parameters.CustomCondition }}
2730

28-
- task: npmAuthenticate@0
29-
displayName: Authenticate .npmrc
30-
condition: ${{ parameters.CustomCondition }}
31-
inputs:
32-
workingFile: ${{ parameters.npmrcPath }}
33-
azureDevOpsServiceConnection: ${{ parameters.ServiceConnection }}
31+
- ${{ if not(parameters.SkipAuthentication) }}:
32+
- task: npmAuthenticate@0
33+
displayName: Authenticate .npmrc
34+
condition: ${{ parameters.CustomCondition }}
35+
inputs:
36+
workingFile: ${{ parameters.npmrcPath }}
37+
azureDevOpsServiceConnection: ${{ parameters.ServiceConnection }}

eng/common/pipelines/templates/steps/create-tags-and-git-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ parameters:
66
RepoId: $(Build.Repository.Name)
77
WorkingDirectory: ''
88
ScriptDirectory: eng/common/scripts
9+
NpmConfigUserConfig: ''
910

1011
steps:
1112
- task: PowerShell@2
@@ -23,3 +24,5 @@ steps:
2324
timeoutInMinutes: 5
2425
env:
2526
GH_TOKEN: $(azuresdk-github-pat)
27+
${{ if ne(parameters.NpmConfigUserConfig, '') }}:
28+
NPM_CONFIG_USERCONFIG: ${{ parameters.NpmConfigUserConfig }}

eng/common/pipelines/templates/steps/update-docsms-metadata.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ parameters:
2929
- name: PackageSourceOverride
3030
type: string
3131
default: ''
32+
- name: NpmConfigUserConfig
33+
type: string
34+
default: ''
3235
steps:
3336
- ${{ if eq(length(parameters.PackageInfoLocations), 0) }}:
3437
- pwsh: |
@@ -91,6 +94,9 @@ steps:
9194
-RepoId '${{ parameters.RepoId }}' `
9295
-PackageSourceOverride '${{ parameters.PackageSourceOverride }}'
9396
displayName: Apply Documentation Updates
97+
env:
98+
${{ if ne(parameters.NpmConfigUserConfig, '') }}:
99+
NPM_CONFIG_USERCONFIG: ${{ parameters.NpmConfigUserConfig }}
94100
95101
- template: /eng/common/pipelines/templates/steps/git-push-changes.yml
96102
parameters:

0 commit comments

Comments
 (0)