Azure Devops从Docker内部的Azure Artifacts安装Python程序包 [英] Azure Devops install Python package from Azure Artifacts inside Docker

查看:93
本文介绍了Azure Devops从Docker内部的Azure Artifacts安装Python程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从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开发中,我不断获得

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?

我们可以使用

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.

然后将其传递给构建arg:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆