Sync eng/common directory with azure-sdk-tools for PR 14353#45530
Sync eng/common directory with azure-sdk-tools for PR 14353#45530chidozieononiwu merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR syncs the eng/common directory with the upstream azure-sdk-tools PR #14353. The change replaces the inline step that deleted the repo-level .npmrc file (to force use of the default npmjs registry) with a new reusable template that instead explicitly sets the project-level npm registry via npm config set registry --location=project, providing better verification and reusability.
Changes:
- Introduces a new reusable pipeline template
reset-npmrc.ymlthat sets (and verifies) the project-level npm registry. - Refactors
npm-publish.ymlto call the new template instead of inline-deleting the.npmrcfile.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
eng/common/pipelines/templates/steps/reset-npmrc.yml |
New reusable template that sets the project-level npm registry via npm config set and verifies the result |
eng/common/pipelines/templates/jobs/npm-publish.yml |
Replaces the inline "Delete repo .npmrc" step with a call to the new reset-npmrc.yml template |
| - task: PowerShell@2 | ||
| displayName: 'Set project npm registry' | ||
| inputs: | ||
| targetType: inline | ||
| script: | | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| Write-Host "Registry before update:" | ||
| npm config get registry --location=project | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to read current project npm registry." | ||
| } | ||
|
|
||
| npm config set registry "${{ parameters.Registry }}" --location=project | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to set project npm registry to '${{ parameters.Registry }}'." | ||
| } | ||
|
|
||
| Write-Host "Registry after update:" | ||
| $updatedRegistry = npm config get registry --location=project | ||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "Failed to read updated project npm registry." | ||
| } | ||
|
|
||
| if ($updatedRegistry.Trim() -ne "${{ parameters.Registry }}") { | ||
| throw "Project npm registry mismatch. Expected '${{ parameters.Registry }}' but got '$updatedRegistry'." | ||
| } | ||
| pwsh: true |
There was a problem hiding this comment.
The old "Delete repo .npmrc" step had condition: and(succeeded(), ne(variables['SkipPublishing'], 'true')), meaning it was skipped when no packages were found (SkipPublishing set to true). The new reset-npmrc.yml template exposes no condition parameter, and the call site in npm-publish.yml does not set one either — so the registry reset step will now run unconditionally even when SkipPublishing is true. This is inconsistent with the EsrpRelease@9 step immediately following it (which retains the SkipPublishing condition check). Consider either adding a CustomCondition parameter to reset-npmrc.yml (following the pattern in create-authenticated-npmrc.yml) or adding condition: and(succeeded(), ne(variables['SkipPublishing'], 'true')) to the template step directly.
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#14353 See eng/common workflow