Azure Devops 从 Docker 内的 Azure Artifacts 安装 Python 包 [英] Azure Devops install Python package from Azure Artifacts inside Docker
问题描述
我正在尝试从 Azure Artifacts 安装一个 pip 包作为 Docker 映像的一部分(使用 Docker@2
任务),但无论我尝试什么都不起作用.
I am trying to install a pip package from Azure Artifacts as part of a Docker image(with Docker@2
task) but whatever I try does not work.
看起来我在 Docker 中的 pip
无论如何都无法针对 Azure Artifacts 进行身份验证.我得到的最接近的是
It looks like my pip
inside Docker cannot authenticate against Azure Artifacts whatever I try. Closest I got is with
RUN pip install keyring artifacts-keyring
ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE true
RUN pip install <> --index-url https://pkgs.dev.azure.com/<>/_packaging/<>/pypi/simple/
但在我的 Azure DevOps 中,我不断收到
but in my Azure devops, i keep getting
ERROR: Could not find a version that satisfies the requirement <> (from versions: none)
ERROR: No matching distribution found for <>
此外 - 关于这方面的 Azure 文档似乎很差,如果我切换 ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE false
它会提示我的 Azure DevOps 管道进行交互身份验证,这不是我想要的.
Also - Azure documentation on this seems to very poor, if I switch ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE false
it prompts my Azure DevOps pipeline to authenticate intercatively which is not what I want.
如何自动安装在 Azure Artifacts 中发布的 Python 包作为我的 Azure Pipeline Docker 任务的一部分?
How can I install a Python package published in Azure Artifacts as part of my Azure Pipeline Docker task automatically?
推荐答案
如何自动安装在 Azure Artifacts 中发布的 Python 包作为我的 Azure Pipeline Docker 任务的一部分?
How can I install a Python package published in Azure Artifacts as part of my Azure Pipeline Docker task automatically?
我们可以使用 PipAuthenticate 任务来填充 PIP_EXTRA_INDEX_URL
环境变量:
We could use the PipAuthenticate task to populates the PIP_EXTRA_INDEX_URL
environment variable:
它使用您的工件提要进行身份验证,并根据文档将存储可用于连接的配置文件的位置PYPIRC_PATH 环境变量.
It authenticates with your artifacts feed and per the docs, will store the location of a config file that can be used to connect in the PYPIRC_PATH environment variable.
然后在构建参数中传递它:
Then pass it in the build arg:
arguments: --build-arg INDEX_URL=$(PIP_EXTRA_INDEX_URL)
您可以查看此文档在 Docker 中使用 Azure Pipelines Python 工件提要了解更多详细信息.
You could check this document Consuming Azure Pipelines Python artifact feeds in Docker for some more details.
希望这会有所帮助.
这篇关于Azure Devops 从 Docker 内的 Azure Artifacts 安装 Python 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!