File tree Expand file tree Collapse file tree
common/pipelines/templates/steps Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ parameters :
2+ - name : npmrcPath
3+ type : string
4+ # When empty, defaults to the agent user's .npmrc ($HOME/.npmrc on
5+ # Linux/macOS, %USERPROFILE%\.npmrc on Windows) so every subsequent
6+ # npm / pnpm / npx call in the job inherits the registry + auth.
7+ default : " "
8+ - name : registryUrl
9+ type : string
10+ default : " https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/"
11+ - name : CustomCondition
12+ type : string
13+ default : succeeded()
14+ - name : ServiceConnection
15+ type : string
16+ default : " "
17+
18+ steps :
19+ - pwsh : |
20+ $npmrcPath = '${{ parameters.npmrcPath }}'
21+ if (-not $npmrcPath) { $npmrcPath = Join-Path $HOME '.npmrc' }
22+
23+ Write-Host "Creating .npmrc file $npmrcPath for registry ${{ parameters.registryUrl }}"
24+ $parentFolder = Split-Path -Path $npmrcPath -Parent
25+
26+ if ($parentFolder -and -not (Test-Path $parentFolder)) {
27+ Write-Host "Creating folder $parentFolder"
28+ New-Item -Path $parentFolder -ItemType Directory | Out-Null
29+ }
30+
31+ "registry=${{ parameters.registryUrl }}" | Out-File $npmrcPath
32+ Write-Host "##vso[task.setvariable variable=resolvedNpmrcPath]$npmrcPath"
33+ displayName: "Create .npmrc"
34+ condition: ${{ parameters.CustomCondition }}
35+
36+ - task : npmAuthenticate@0
37+ displayName : Authenticate .npmrc
38+ condition : ${{ parameters.CustomCondition }}
39+ inputs :
40+ workingFile : $(resolvedNpmrcPath)
41+ azureDevOpsServiceConnection : ${{ parameters.ServiceConnection }}
Original file line number Diff line number Diff line change 77 - task : UseDotNet@2
88 inputs :
99 version : 6.x
10+ - template : /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml
1011 - script : npm ci
1112 displayName : npm ci
1213 - script : npm run lint
You can’t perform that action at this time.
0 commit comments