我可以使用pip从私有VSTS存储库安装软件包吗? [英] Can I use pip to install a package from a private VSTS repository?
问题描述
我想使用pip为我的python应用安装私有软件包.
I would like to install a private package for my python app with pip.
我的软件包存储在 Azure DevOps (Visual Studio Team Services)上的git仓库中.
My package is stored in a git repo on Azure DevOps (Visual Studio Team Services).
我看到 git受pip支持,但我无法确定Azure URL的可行格式.
I see that git is supported by pip, but I cannot determine a workable format for the URL for Azure.
我想避免使用凭据管理器.我已经尝试了git + ssh(带密钥)和git + https(带个人访问令牌).
I would like to avoid the Credential Manager. I have tried both git+ssh (with key) and git+https (with Personal Access Token).
是否可以使用Azure/VSTS做到这一点?
Is it possible to do this with Azure/VSTS?
对于上下文,我引用了以下资源:
For context, I referenced these resources:
https://www.revsys.com/tidbits/using-private-packages-python/
这是我的一些尝试:
git+https://myUsername:myAccessToken@myCompany.visualstudio.com/myProject/_git/myPackage.git
git+https://<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@<myCompany>.visualstudio.com/<myteam>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+https://<myUsername>:<myAccessToken>@visualstudio.com/<myCompany>/<myProject>.git@<ref>
git+ssh://myCompany@vs-ssh.visualstudio.com:v3/myCompany/<myProject>.git@<ref>
推荐答案
It is possible, please have a look it to this existing Request
因此,您需要执行以下步骤,
As per that, you need to follow the below steps,
- 检查允许"脚本以访问代理"作业中的OAuth令牌阶段
- 包括任务:命令行
- 在回购克隆URL之间添加
$(System.AccessToken)
This above is the System variable, you can find the full details here
您还可以使用如下所示的Rest API,用于获取访问令牌
$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build-release/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
Write-Host "URL: $url"
$pipeline = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 1000)"
这篇关于我可以使用pip从私有VSTS存储库安装软件包吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!