首页 > 解决方案 > go get 和 AzureDevOps 身份验证不起作用

问题描述

我拼命想弄清楚为什么go getAzureDevOps 上的 Git 存储库中的包中的命令不起作用。

两个 golang 项目(包所在的项目以及尝试导入它的消费者)都位于同一个 AzureDevOps 项目中。我正在尝试将一个包从一个包导入另一个包,但无济于事。

我按照此处的说明进行操作:https ://docs.microsoft.com/en-us/azure/devops/repos/git/go-get?view=azure-devops

我已经创建了一个 PAT 并测试了我能够从我想要从中导入包的位置克隆存储库,并且效果很好。

git clone https://me:78rt5u89dg635ef4fb30e4b0229e4329756986416673b4e331ag@dev.azure.com/my-comp/my-proj/_git/k8s-team-operator

所以我在我的脑海中(也许是错误的)假设 PAT 能够正确地进行身份验证。也就是说,不幸的是,我不得不使用 cntlm 代理才能到外面,但这通常效果很好。

在终端内的 golang 项目中,我设置了:export GOPRIVATE=dev.azure.com

在位于 ~/.gitconfig 的 GitConfig 文件中,我设置了以下值:

# This is Git's per-user configuration file.
[user]
        email = me@my-comp.com
        name = Morné Kruger

[core]
        editor = vi

[url https://me:78rt5u89dg635ef4fb30e4b0229e4329756986416673b4e331a@dev.azure.com/my-comp/my-proj/_git/k8s-team-operator]
    insteadOf = https://dev.azure.com/my-comp/my-proj/_git/k8s-team-operator

然后我运行带有详细标志的 go get 命令,然后得到以下不太积极的响应:

me@focalfossa:~/dev/my-comp/repos/k8s-teamapi-functions$ go get -x dev.azure.com/my-comp/my-proj/_git/k8s-team-operator.git
# get https://dev.azure.com/my-comp/my-proj/_git?go-get=1
# get https://dev.azure.com/?go-get=1
# get https://dev.azure.com/my-comp?go-get=1
cd .
git ls-remote https://dev.azure.com/my-comp/my-proj/_git/k8s-team-operator
# get https://dev.azure.com/my-comp/my-proj?go-get=1
cd .
git ls-remote git+ssh://dev.azure.com/my-comp/my-proj/_git/k8s-team-operator
# get https://dev.azure.com/?go-get=1: 403 Forbidden (0.274s)
# get https://dev.azure.com/my-comp/my-proj?go-get=1: 203 Non-Authoritative Information (0.307s)
# get https://dev.azure.com/my-comp?go-get=1: 203 Non-Authoritative Information (0.308s)
# get https://dev.azure.com/my-comp/my-proj/_git?go-get=1: 203 Non-Authoritative Information (0.311s)
cd .
git ls-remote ssh://dev.azure.com/my-comp/my-proj/_git/k8s-team-operator
mkdir -p /home/me/go/pkg/mod/cache/vcs # git3 git://dev.azure.com/my-comp/my-proj/_git/k8s-team-operator
# lock /home/me/go/pkg/mod/cache/vcs/540338d35ef4fb30e4b0229e4329756986416673b4e3318516900fca1efcee17.lock# /home/me/go/pkg/mod/cache/vcs/540338d35ef4fb485763tg30417801e630216673b4e3318516900fca1efcee17 for git3 git://dev.azure.com/my-comp/my-proj/_git/k8s-team-operator
cd /home/me/go/pkg/mod/cache/vcs/540338d35ef4fb30e4b02906874yh25630216673b4e3318516900fca1efcee17; git ls-remote -q origin
2.083s # cd /home/me/go/pkg/mod/cache/vcs/540338d35ef49059y87e329e417801e630216673b4e3318516900fca1efcee17; git ls-remote -q origin
go get: module dev.azure.com/my-comp/my-proj/_git/k8s-team-operator.git: git ls-remote -q origin in /home/me/go/pkg/mod/cache/vcs/540338d35ef4fb30e4b022125f7y879430216673b4e3318516900fca1efcee17: exit status 128:
        fatal: unable to connect to dev.azure.com:
        dev.azure.com[0: 13.107.42.20]: errno=Connection refused
        dev.azure.com[1: 2620:1ec:21::20]: errno=Network is unreachable

版本:
go1.16.5 linux/amd64
Ubuntu 20.04
GoLand 2021.1.2
git 版本 2.25.1

我将非常感谢任何可以指出我的错误的提示或故障排除想法!

标签: goazure-devopsgoland

解决方案


推荐阅读