[英]Installing packages from Azure DevOps Artifact Feed in a Azure Pipeline
我有两个存储库。
我本地可以安装,但是第二个package的pipeline失败了。 当管道失败时,我收到以下错误:
401 Client Error: Unauthorized for url:
https://pkgs.dev.azure.com/<company>/<some-numbers>/_packaging/<some-numbers>/pypi/download/<mypackage>/0.0.1.9/<mypackage>-0.0.1.9-py3-none-any.whl#sha256=<some-numbers>
- - - - - - - - - - - - - - - - - 设置 - - - - - - - - ------------------
我将提要作为第二个源添加到我的第二个存储库的pyproject.toml中,这使我能够成功安装第一个 package,并为我的本地 IDE 安装poetry add <firstpackage>
和poetry install
:
[[tool.poetry.source]]
name = "azure"
url = "https://pkgs.dev.azure.com/<company>/<some-numbers>/_packaging/<feed-name>/pypi/simple/"
secondary = true
YAML 通过诗歌安装包的脚本 -适用于第一个存储库,但不适用于需要从 Azure DevOps artifcats 提要安装第一个 package 的第二个存储库(第一个安装来自 pypi.org 的所有内容):
- script: |
python -m pip install -U pip
pip install poetry==1.1.3 # Install poetry via pip to pin the version
poetry install
displayName: Install software
YAML 脚本将 package 发布到 Azure DevOps 工件提要(使用个人访问令牌作为身份验证)-有效:
- script: |
poetry config repositories.azure https://pkgs.dev.azure.com/<company>/<somenumbers>/_packaging/<feed-name>/pypi/upload/
poetry config http-basic.azure usernamedoesnotmatter $(pat)
poetry publish --repository azure
exit 0
displayName: Publish package
我没有将我的个人访问令牌 (PAT) 检查到我的存储库中。
pyproject.toml(部分):
[[tool.poetry.source]]
name = "azure"
url = "https://pkgs.dev.azure.com/<company>/<some-numbers>/_packaging/<feed-name>/pypi/simple/"
secondary = true
我添加了PipAuthenticate@1
任务来设置包含 PAT 的PIP_EXTRA_INDEX_URL
环境变量。 在脚本中,我提取 PAT 并使用它来配置诗歌。
azure-pipelines.yaml(部分):
- task: PipAuthenticate@1
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: '<some-numbers>/<feed-name>'
onlyAddExtraIndex: True
- script: |
python -m pip install --upgrade pip
pip install poetry
export PAT=$(echo "$PIP_EXTRA_INDEX_URL" | sed 's/.*build:\(.*\)@pkgs.*/\1/')
poetry config http-basic.azure build "$PAT"
poetry install
displayName: "Install dependencies"
事实证明,我只需要在安装第二个存储库之前在管道中配置 poetry - 就像很久以前我在本地所做的一样(并且忘记了它)。
- script: |
python -m pip install -U pip
pip install poetry==1.1.3 # Install poetry via pip to pin the version
# configuring the feed as a secondary source for poetry
poetry config repositories.azure https://pkgs.dev.azure.com/<company>/<some-numbers>/_packaging/<feed-name>/pypi/simple/
poetry config http-basic.azure userNameDoesntMatter $(pat)
poetry install
displayName: Install software
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.