我在我的应用程序中遇到身份验证问题。我使用dotnet publish在我的Azure Pipeline中构建它,在那里我运行npm install。我已经配置了.npmrc文件,因为我使用两个注册表(一个npm,另一个来自Azure Artifacts)。我仍然收到401 unathenticate。
如何使用PAT对注册表进行身份验证?PAT设置正确。@first_registry:registry=https://myregistry/:_authToken=${token} always-auth=true
不工作
1条答案
按热度按时间2exbekwf1#
对于管道的身份验证,建议使用npm authenticate task而不是PAT。
对于管道的身份验证,Azure Artifacts建议使用npm authenticate task。使用gulp或Grunt等任务运行器时,将npm authenticate任务添加到管道的开头非常重要。通过这样做,您的凭据将注入到项目的.npmrc文件中,并在管道运行期间保持,从而使后续步骤能够使用配置文件中的凭据。
因此,请尝试在管道的开头添加npm authenticate task(至少在
npm install
和dotnet publish
步骤之前)。字符串
请注意,要授予您的管道访问您的提要的权限,请确保您在提要设置中将
build service
角色设置为Contributor
。有关详细信息,请参阅Pipeline身份验证。