【发布时间】:2018-02-08 20:20:00
【问题描述】:
我正在尝试从 VSTS 克隆存储库。 我正在尝试使用 powershell 并使用除了 MyVSAccount.VisualStudio.com 之外无法访问 Internet 的服务器,以便我可以克隆存储库。
我可以使用我的用户名和令牌与我的 VS 帐户“交谈”。我会返回我所有存储库的列表以及有关它们的信息。
但是,之后,我在尝试克隆它时遇到错误。它只是说:连接到 MyVSAccount.VisualStudio.com 被拒绝。
使用提琴手,我可以看到,只有当我检索存储库列表时,我的 VS 帐户才会有 http 请求。克隆时,没有,所以不应该拒绝。另外,可以访问我帐户的那个地址,所以克隆应该没有问题。
有人对此提出建议吗?我不明白为什么当有检索存储库列表的 http 请求时,一切都成功,而在克隆时却没有,即使没有用于克隆的 http 请求。
是否需要在代码中插入代理设置?
要克隆的代码
git clone --mirror $url
使用令牌检索存储库列表的代码。
$url = $h.Get_Item("Url")
$username = $h.Get_Item("Username")
$password = $h.Get_Item("Password")
# Retrieve list of all repositories
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$headers = @{
"Authorization" = ("Basic {0}" -f $base64AuthInfo)
"Accept" = "application/json"
}
Add-Type -AssemblyName System.Web
$gitcred = ("{0}:{1}" -f [System.Web.HttpUtility]::UrlEncode($username),$password)
$resp = Invoke-WebRequest -Headers $headers -Uri ("{0}/_apis/git/repositories?api-version=1.0" -f $url)
$json = convertFrom-JSON $resp.Content
错误:
致命:无法访问 'MyVSAccount.visualstudio.com/MyProject/_git/Tests/';:不能 解析主机:myvsaccount.visualstudio.com
我也尝试设置代理:
$proxyString = "http://proxy-s-app.mynet.net:80"
$proxyUri = new-object System.Uri($proxyString)
[System.Net.WebRequest]: : DefaultWebProxy = new-object System.Net.WebProxy ($proxyUri, $true)
【问题讨论】:
标签: git powershell proxy azure-devops