首页 > 解决方案 > 无法从 AppCenter 构建管道对 Azure DevOps Artifacts 源进行身份验证

问题描述

我在 appcenter 上构建了一个 ReactNative iOS 应用程序,它无法访问 Azure DevOps Artifacts 上的 npm 提要。这是该项目的工件。我尝试了一切,但没有看到问题。

项目根 .npmrc

@scope:registry=https://pkgs.dev.azure.com/org/_packaging/feed-name/npm/registry/

appcenter-post-clone.sh

# PACKAGES_READ_PASSWORD is PAT with packages read & write persmissions

PACKAGES_READ_PASSWORD_BASE64=$(echo ${PACKAGES_READ_PASSWORD} | base64)

cat >> ${HOME}/.npmrc << EOF

; begin auth token
//pkgs.dev.azure.com/org/_packaging/feed-name/npm/registry/:username=org
//pkgs.dev.azure.com/org/_packaging/feed-name/npm/registry/:_password=${PACKAGES_READ_PASSWORD_BASE64}
//pkgs.dev.azure.com/org/_packaging/feed-name/npm/registry/:email=sample@email.com

//pkgs.dev.azure.com/org/_packaging/feed-name/npm/:username=org
//pkgs.dev.azure.com/org/_packaging/feed-name/npm/:_password=${PACKAGES_READ_PASSWORD_BASE64}
//pkgs.dev.azure.com/org/_packaging/feed-name/npm/:email=sample@email.com
; end auth token
EOF

在 npm install 阶段,这是输出

npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/"

我正在使用以下机器配置运行管道

Agent name: 'Hosted Agent'
Agent machine name: 'Mac-1622549610698'
Current agent version: '2.187.1'
##[group]Operating System
Mac OS X
10.15.7
19H1217
##[endgroup]
##[group]Virtual Environment
Environment: macos-10.15
Version: 20210525.2
Included Software: https://github.com/actions/virtual-environments/blob/macOS-10.15/20210525.2/images/macos/macos-10.15-Readme.md
Image Release: https://github.com/actions/virtual-environments/releases/tag/macOS-10.15%2F20210525.2
##[endgroup]
Current image version: '20210525.2'
Agent running as: 'runner'
Prepare build directory.
Set build variables.
Download all required tasks.
Downloading task: PowerShell (2.186.0)
Downloading task: ShellScript (2.165.2)
Downloading task: Bash (3.182.0)
Downloading task: CmdLine (1.1.3)
Downloading task: CmdLine (2.182.0)
Downloading task: InstallAppleCertificate (2.186.0)
Downloading task: InstallAppleProvisioningProfile (0.124.0)
Downloading task: CocoaPods (0.186.0)
Downloading task: Xcode (4.130.0)
Downloading task: CopyFiles (2.186.1)
Downloading task: PublishBuildArtifacts (1.186.0)

谢谢您的帮助

标签: azure-devopsvisual-studio-app-centernpm-registry.npmrc

解决方案


推荐阅读