Minimal custom Azure DevOps task inspired by NpmAuthenticateV0, but targeting .yarnrc.yml.
What it does
- Reads a
.yarnrc.ymlfile fromworkingFile. - Reads service connection credentials from
customEndpoint(comma-separated IDs). - Matches service-connection registry URLs to
npmScopes.*.npmRegistryServer. - Writes auth into:
npmScopes[scope].npmAuthTokenornpmAuthIdentnpmRegistries[registry].npmAuthTokenornpmAuthIdent
- Sets
npmAlwaysAuth: truefor matched entries.
Structure
Tasks/YarnrcAuthenticate/task.jsonTasks/YarnrcAuthenticate/src/yarnrcauth.tsTasks/YarnrcAuthenticate/dist/yarnrcauth.js(generated)package.jsontsconfig.json
Install deps
yarn install
yarn build
Use in pipeline (after packaging and publishing the custom task)
- task: YarnrcAuthenticate@1
inputs:
workingFile: $(Build.SourcesDirectory)/.yarnrc.yml
customEndpoint: your-service-connection-id
Notes
workingFilemust be.yarnrc.ymlor.yarnrc.yaml.- If no
customEndpointis provided, task exits with warning and no file changes.
License
This project is licensed under the Apache 2.0 — see the LICENSE file for details.