簡體   English   中英

我可以使用pip從私有VSTS存儲庫安裝包嗎?

[英]Can I use pip to install a package from a private VSTS repository?

我想用pip為我的python app安裝一個私有包。

我的包存儲在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/

是否可以使用pip從私有github存儲庫安裝包?

以下是我的一些嘗試:

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令牌
  • 包括任務:命令行
  • 在repo clone URL之間添加$(System.AccessToken)

以上是System變量,您可以在此處找到完整的詳細信息

您還可以使用下面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)"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM