diff --git a/eng/common/pipelines/templates/steps/authenticate-temp-npmrc.yml b/eng/common/pipelines/templates/steps/authenticate-temp-npmrc.yml new file mode 100644 index 0000000000..6ffd7fb174 --- /dev/null +++ b/eng/common/pipelines/templates/steps/authenticate-temp-npmrc.yml @@ -0,0 +1,21 @@ +parameters: + RepoNpmrc: '$(Build.SourcesDirectory)/.npmrc' + +steps: + - pwsh: | + $repoNpmrc = "${{ parameters.RepoNpmrc }}" + $tempNpmrc = "$(Agent.TempDirectory)/.npmrc" + + if (Test-Path $repoNpmrc) { + Copy-Item $repoNpmrc $tempNpmrc -Force + } else { + New-Item -Path $tempNpmrc -ItemType File -Force | Out-Null + } + + Write-Host "##vso[task.setvariable variable=NPM_CONFIG_USERCONFIG]$tempNpmrc" + displayName: "Prepare temp .npmrc from repo config" + + - task: npmAuthenticate@0 + displayName: "Authenticate temp .npmrc" + inputs: + workingFile: $(NPM_CONFIG_USERCONFIG)