Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Authentication 如何使用azure devops构建管道验证npm注册表?_Authentication_Npm_Azure Devops - Fatal编程技术网

Authentication 如何使用azure devops构建管道验证npm注册表?

Authentication 如何使用azure devops构建管道验证npm注册表?,authentication,npm,azure-devops,Authentication,Npm,Azure Devops,我有一个应用程序正在Azure DevOps中创建一个构建管道。它使用npm包,这些包位于私有npm注册表中(代码由不同的Azure DevOps组织创建)。当我运行npm ci(或npm install)时,它会失败,并出现以下错误: npm错误!代码E401 npm错误!无法进行身份验证,需要:承载授权\u uri=,基本域=”https://pkgsproduks1.pkgs.visualstudio.com/“,TFS联合 失败的特定软件包是来自其他组织的软件包,在尝试获取它们时返回40

我有一个应用程序正在Azure DevOps中创建一个构建管道。它使用npm包,这些包位于私有npm注册表中(代码由不同的Azure DevOps组织创建)。当我运行
npm ci
(或
npm install
)时,它会失败,并出现以下错误:

npm错误!代码E401

npm错误!无法进行身份验证,需要:承载授权\u uri=,基本域=”https://pkgsproduks1.pkgs.visualstudio.com/“,TFS联合

失败的特定软件包是来自其他组织的软件包,在尝试获取它们时返回
401

我认为对其进行身份验证的最佳实践是在Azure DevOps中创建服务连接。我已经在承载npm包的组织中创建了个人访问令牌,并使用它在包含我的构建管道的组织中创建服务连接。然后,我将其包括在我的构建管道yaml中,如下所示:

-任务:Npm@1
displayName:安装npm软件包
投入:
命令:“ci”
workingDir:'Path/To/Working/Directory'
customEndpoint:“自定义npm注册表”
在此之前,我还尝试过使用
npm authenticate
构建步骤(在安装步骤中使用和不使用
customEndpoint:'Custom npm registry'
),虽然
npm authenticate
成功运行,但它不会对我遇到的错误产生任何影响。我还尝试设置服务连接,使用我的用户名和密码,而不是PAT,但这也没有什么区别

我的项目中的
.npmrc
如下所示(稍作修改):


任何人都可以看到身份验证有什么问题,或者链接到一篇文章,该文章给出了跨多个Azure DevOps组织执行此操作的示例?

.npmrc
应该如下所示:

registry=https://pkgs.dev.azure.com/{organization}/{project}/_packaging/{feed}/npm/registry/
@{scope}:registry=https://pkgs.dev.azure.com/{otherorganization}/_packaging/{feed}/npm/registry/
@{otherscope}:registry=https://{thirdPartyRepository}/npm/registry/
always-auth=true

检查这里:你的问题进展如何?谢谢跟进。我需要转移到其他方面,所以我暂时删除了对其他注册表的依赖,但当我需要再次查看时,我会回到您的答案。我也一直在努力解决这个问题几个月了。我已经使用PAT身份验证将外部提要作为服务添加,但没有任何效果。除非我误解了这一点,否则没有任何区别。我现在有了
@{scope}:registry=https://pkgs.dev.azure.com/{otherorganization}/_packaging/{feed}/npm/registry/always auth=true
但仍然会得到相同的错误。
registry=https://pkgs.dev.azure.com/{organization}/{project}/_packaging/{feed}/npm/registry/
@{scope}:registry=https://pkgs.dev.azure.com/{otherorganization}/_packaging/{feed}/npm/registry/
@{otherscope}:registry=https://{thirdPartyRepository}/npm/registry/
always-auth=true