Publish npm packages (YAML/Classic)
Azure Pipelines | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 | TFS 2017
Using Azure Pipelines, you can publish your npm packages to Azure Artifacts feeds or to public registries such as npmjs.com. Using the npm task, you can install or publish npm packages as well as run any npm commands.
Publish to Azure Artifacts feeds
To publish your npm packages to Azure Artifacts feeds from your Pipeline, you must first provide a Contributor access to the Project Collection Build Service identity. See Add new users/groups for more details.
Add the npm task to your yaml pipeline as follows to publish your package to your feed.
- task: Npm@1
inputs:
command: publish
publishRegistry: useFeed
publishFeed: <PROJECT_NAME>/<FEED_NAME>
- useFeed: select this option to use a feed in the same organization as the build.
YAML is not supported in TFS.
Publish to a public registry
To publish your packages to a public npm registry such as npmjs.com, you must first create a service connection to connect to the desired external service.
You can do this by going to your Project settings then selecting Service connections.
Select Create service connection to create a new service connection.
Select npm then fill out the required fields. Select Save when you are done.
See Manage service connections to learn more about how to create, manage, secure, and use service connections.
To publish a package to an npm registry, add the following snippet to your yaml file.
- task: Npm@1
inputs:
command: publish
publishRegistry: useExternalRegistry
publishEndpoint: '<NAME_OF_YOUR_SERVICE_CONNECTION>'
- publishEndpoint: required when
publishRegistry == useExternalRegistry. Copy and paste the name of the service connection you created earlier.
YAML is not supported in TFS.