When creating the feed, setting feed permissions, and a creating a build to assemble and publish the npm package there are a few things you need to get correct to get it all to work.
Make sure the is a .npmrc file in the working folder when using npm build steps
If there is a .npmrc file in the working folder the task output will show SYSTEMVSSCONNECTION exists true
followed by a call to vsts-npm-auth.exe to setup the authorization. Because we set the working folder of this build step to the package location, which did not have the needed .npmrc file, we received this error
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`
The second line is actually wrong for TFS builds. Once we realized that we updated the build step to set the working folder back to where th .npmrc file was and pass the directory in as the argument to the task.
We had thought that adding a default .npmrc file on the build machine would fix it so we followed the steps to setup your client's nmprc file, but found that the build task looks specifically in the working directory for the file, so that didn't work. Also we noted that the build agents do not need an auth token in the project specific or local .npmrc files as you do to use the feed.
Make sure the build job authorization scope is set to project collection
Our build defaulted to an authorization scope of current project. The important thing to understand is that a feed in TFS is not at the project level, it is at the collection level. Because the authorization scope was set to current project the build failed with the error npm ERR! Forbidden Build\24de1053-452f-41d5-9abb-48c88b6db484 lacks permission to complete this action. You need to have 'AddPackage'.: tfs
Setting the build job authorization scope, on the Options page of the build, to project collection fixed this issue.
Lastly, a note of caution, you may not want to push all the packages you build to your feed, we use a custom build step condition to make sure we only push builds on master with the correct tags on the commit.
Thanks for stopping by.
With TFS2017, you can introduce an augmentation that permits your TFS plugin to have private NuGet bundles. It's around 10 ticks to understand that introduced and after that you can begin distributing and facilitating NuGet bundles that you can utilize inside to your organization.
ReplyDelete