活动
PipAuthenticate@1 - Python pip 身份验证 v1 任务
使用此任务为安装 Python 分发版的 pip
客户端提供身份验证。
# Python pip authenticate v1
# Authentication task for the pip client used for installing Python distributions.
- task: PipAuthenticate@1
inputs:
# Feeds and Authentication
#artifactFeeds: # string. My feeds (select below).
#pythonDownloadServiceConnections: # string. Feeds from external organizations.
#onlyAddExtraIndex: false # boolean. Don't set primary index URL. Default: false.
artifactFeeds
-
我的源(选择下方)
string
。
指定使用 pip 进行身份验证的 Azure Artifacts 源的逗号分隔列表。
从外部组织 pythonDownloadServiceConnections
- 源
string
。
指定从外部组织 名称
onlyAddExtraIndex
-
不要设置主索引 URL
boolean
。 默认值:false
。
如果此任务设置为 true
,则不会将源设置为主索引 URL。 所有配置的源/终结点都将设置为额外的索引 URL。
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
没有。
为用于安装 Python 分发版的 pip
客户端提供身份验证。
- 我的管道中何时应运行此任务?
- 如果希望管道能够从上游源进行保存,该怎么办?
- 我的代理位于 Web 代理后面。 PipAuthenticate 是否会设置 pip 以使用我的代理?
- 我的管道需要访问其他项目中的源
在使用 pip 将 Python 分发版下载到经过身份验证的包源(例如 Azure Artifacts)之前,必须运行此任务。 没有其他订购要求。 此任务的多个调用不会堆叠凭据。 每次运行任务都会清除以前存储的任何凭据。
检查 权限表 以确定希望管道拥有哪些权限。 然后,确定要向其授予这些权限的 标识。 若要从上游源保存包,标识需要 Feed and Upstream Reader (Collaborator)
权限。
不。 虽然此任务本身将在 Web 代理后面工作,但代理已配置为使用,但它不会将 pip 配置为使用代理。
为此,可以:
- 将环境变量
http_proxy
、https_proxy
和选择性地no_proxy
设置为代理设置。 有关详细信息,请参阅 Pip 官方指南。 这些是常用的变量,其他非 Python 工具(例如 curl)也可以使用这些变量。注意
Linux 和 Mac 操作系统上的
http_proxy
和no_proxy
变量区分大小写,并且必须小写。 尝试使用 Azure Pipelines 变量设置环境变量将不起作用,因为它将转换为大写。 而是在自承载代理的计算机上设置环境变量,然后重启代理。 - 使用
proxy
密钥将代理设置添加到 pip 配置文件 文件。 - 使用
--proxy
命令行选项以[user:passwd@]proxy.server:port
形式指定代理。
如果管道在与托管源的项目不同的项目中运行,则必须设置其他项目以授予对生成服务的读/写访问权限。 有关详细信息,请参阅 Azure Pipelines 中的
在此示例中,我们将设置从专用 Azure Artifacts 源下载的身份验证。 身份验证任务创建 PIP_INDEX_URL
和下载分发版所需的 PIP_EXTRA_INDEX_URL
环境变量。 该任务使用任务为提供的 Artifacts 源生成的身份验证凭据设置变量。
HelloTestPackage
必须存在于 myTestFeed1
或 myTestFeed2
;否则,安装将失败。
对于与管道运行位置不同的项目中的项目范围源,必须手动为项目和源授予对管道项目的生成服务的访问权限。
- task: PipAuthenticate@1
displayName: 'Pip Authenticate'
inputs:
# Provide list of feed names which you want to authenticate.
# Project scoped feeds must include the project name in addition to the feed name.
artifactFeeds: 'project1/myTestFeed1, myTestFeed2'
# Use command line tool to 'pip install'.
- script: |
pip install HelloTestPackage
在此示例中,我们将设置从专用 Azure Artifacts 源下载的身份验证,但首先会咨询 pypi。 身份验证任务创建环境变量 PIP_EXTRA_INDEX_URL
,其中包含下载分发版所需的身份验证凭据。 仅当 pypi中不存在时,才会从经过身份验证的源下载 HelloTestPackage
。
对于与管道运行位置不同的项目中的项目范围源,必须手动为项目和源授予对管道项目的生成服务的访问权限。
- task: PipAuthenticate@1
displayName: 'Pip Authenticate'
inputs:
# Provide list of feed names which you want to authenticate.
# Project scoped feeds must include the project name in addition to the feed name.
artifactFeeds: 'project1/myTestFeed1, myTestFeed2'
# Setting this variable to "true" will force pip to get distributions from official python registry first and fallback to feeds mentioned above if distributions are not found there.
onlyAddExtraIndex: true
# Use command line tool to 'pip install'.
- script: |
pip install HelloTestPackage
在此示例中,我们将设置从外部 Python 分发服务器下载的身份验证。 为外部服务创建 pip 服务连接 条目。 身份验证任务使用服务连接创建环境变量 PIP_INDEX_URL
,其中包含下载分发版所需的身份验证凭据。
HelloTestPackage
必须存在于 pypitest
服务连接中;否则,安装将失败。 如果希望首先咨询 pypi,请将 onlyAddExtraIndex
设置为 true
。
- task: PipAuthenticate@1
displayName: 'Pip Authenticate'
inputs:
# In this case, name of the service connection is "pypitest".
pythonDownloadServiceConnections: pypitest
# Use command line tool to 'pip install'.
- script: |
pip install HelloTestPackage