gpt4 book ai didi

azure - 在 Azure Pipeline 中安装来自 Azure DevOps Artifact Feed 的包

转载 作者:行者123 更新时间:2023-12-03 02:15:37 24 4
gpt4 key购买 nike

我有两个存储库。

  • 第一个由 AzureDevOps Pipelines 构建为 whl 文件,并发布在 Azure DevOps Artifact feed 上。 (作品)
  • 第二个也应该由 AzureDevOps Pipelines 构建并发布在 Azure DevOps 工件上 -> 但它依赖于第一个,并且需要在构建过程中从 AzureDevops Artifact feed 安装它。(这不起作用)。

我可以在本地安装它,但是第二个包的管道失败。当管道失败时,我收到以下错误:

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 中,这使我能够成功安装第一个包 poetry add <firstpackage>poetry install对于我的本地 IDE:

[[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 feed 安装第一个包(第一个安装来自 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

用于发布包到 Azure DevOps 工件源的 YAML 脚本(使用个人访问 token 作为身份验证) - 有效:

- 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

最佳答案

我没有将我的个人访问 token (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"

关于azure - 在 Azure Pipeline 中安装来自 Azure DevOps Artifact Feed 的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71294997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com