git - 我可以使用 pip 从私有 VSTS 存储库安装包吗?
问题描述
我想用 pip 为我的 python 应用程序安装一个私有包。
我的包存储在Azure DevOps (Visual Studio Team Services) 上的 git 存储库中。
我看到pip 支持 git,但我无法确定 Azure 的 URL 的可行格式。
我想避免使用Credential Manager。我已经尝试过 git+ssh(带密钥)和 git+https(带个人访问令牌)。
是否可以使用 Azure/VSTS 执行此操作?
对于上下文,我参考了以下资源:
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>
解决方案
有可能,请看一下这个现有的请求
据此,您需要按照以下步骤操作,
- 在代理作业阶段检查允许脚本访问 OAuth 令牌
- 包括任务:命令行
$(System.AccessToken)
在 repo 克隆 URL 之间添加
以上是系统变量,您可以在此处找到完整的详细信息
您还可以使用如下所示的 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)"
推荐阅读
- mysql - mariadb 中的“Init for Update”线程状态是什么?
- c# - JsonConverter 处理动态键名
- node.js - 如何在nodejs multer图像上传中定义静态文件夹路径
- linux - 在openGL中关联顶点缓冲区和顶点属性
- excel - excel simple math error 1 - 1.09 = -0.0900000000000001?
- hyperledger-fabric - 如何将更多节点导入本地结构?
- multithreading - AMD SMT 或 Intel HT 性能
- java - 如何将 JsonArray 从 Gson 转换为流
- c - 逐行读取 intex hex 文件并操作数据
- ruby-on-rails - 升级到 Rails 5 后 Ruby 线程不工作