【问题标题】:when will `git ls-remote -q origin` be executed when `go build` using go module?`git ls-remote -q origin` 何时使用 go 模块执行`go build`?
【发布时间】:2022-01-04 08:08:47
【问题描述】:

我的 gitlab 构建管道失败,因为它会运行 git ls-remote -q origin 指令,并报告错误说“找不到您要查找的项目”。

[2022/01/04 15:58:00]  /go/pkg/mod/***/finance/alice@v0.9.63-0.20211231031838-f6dae3fdb8c4/kafkax/kafka_consumer.go:9:2: reading golang.***.com/kit/swimlane/go.mod at revision v0.0.1: git ls-remote -q origin in /go/pkg/mod/cache/vcs/d59e078efe804645d7b0bc877750c96d810a57328e3acc47eb94bdb969209bf9: exit status 128:
[2022/01/04 15:58:00]   > GitLab: The project you were looking for could not be found.
[2022/01/04 15:58:00]   fatal: Could not read from remote repository.
[2022/01/04 15:58:00]   
[2022/01/04 15:58:00]   Please make sure you have the correct access rights
[2022/01/04 15:58:00]   and the repository exists.

其实“swimlane”依赖,不是go模块项目,已经下载好了。

[2022/01/04 15:57:39] go: downloading golang.***.com/kit/swimlane v0.0.1
[2022/01/04 15:57:39] get "golang.***.com/kit/swimlane": found meta tag vcs.metaImport{Prefix:"golang.***.com/kit/swimlane", VCS:"git", RepoRoot:"git+ssh://git@git.***.com/kit/swimlane"} at //golang.***.com/kit/swimlane?go-get=1

但是,由于某种原因我没有弄清楚,似乎是“/kafkax/kafka_consumer.go:9:2”导致它运行“git ls-remote -q origin”以获取远程引用可用于“泳道”。

我使用git ls-remote --get-url origin 来获取原始网址,即“http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.***.com/finance/order-center.git”。 “finance/order-center.git”是 gitlab 管道构建失败的确切项目,但不是“swimlane”的起源。

我正在寻找一种方法来使我的管道成功运行。非常感谢您分享您对此问题的意见或解决方案。

谢谢!!!

附:原来的 git 配置是:

[2022/01/04 15:57:18] Step 12/22 : RUN git config --list
[2022/01/04 15:57:18]  ---> Running in 3170cf53e18e
[2022/01/04 15:57:18] url.http://git.***.com/.insteadof=git+ssh://git@git.***.com/
[2022/01/04 15:57:18] fetch.recursesubmodules=false
[2022/01/04 15:57:18] core.repositoryformatversion=0
[2022/01/04 15:57:18] core.filemode=true
[2022/01/04 15:57:18] core.bare=false
[2022/01/04 15:57:18] core.logallrefupdates=true
[2022/01/04 15:57:18] remote.origin.url=http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.***.com/finance/order-center.git
[2022/01/04 15:57:18] remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
[2022/01/04 15:57:18] branch.master.remote=origin
[2022/01/04 15:57:18] branch.master.merge=refs/heads/master

要使用 ssh 从私有仓库中获取代码,我运行

[2022/01/04 15:57:23] Step 20/22 : RUN git config --global --unset url.http://git.***.com/.insteadof

【问题讨论】:

  • 我的本地 IDE 环境一切正常...

标签: go gitlab gitlab-ci go-modules


【解决方案1】:

您可以检查此代码 https://github.com/golang/go/blob/b1a53ece68d46e4fb59c74d2bc529060861f5dbf/src/cmd/go/internal/vcs/vcs.go#L242-L246 一般在 go get 或下载 mod 时会调用 git ls-remote(go build 会下载当前 build 依赖的远程模块)。

【讨论】:

  • 谢谢。但是我仍然不明白为什么它会在检查或扫描(或做某事?)使用包的“kafkax/kafka_consumer.go:9:2”的代码时获取或下载mod“swimlane”。 mod“swimlane”在主mod中是必需的并且之前已经下载过......并且它在finance / alice mod中是必需的,这也是一个主要的mod依赖......以及重新下载的原因是什么mod泳道的??
  • swinlane mod 是贵公司 gitlab 中的私有 repo 吗?这可能是因为您无法访问 swinlane 存储库。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-04
  • 2013-10-14
  • 2022-01-20
  • 2014-12-11
  • 1970-01-01
  • 2021-12-25
相关资源
最近更新 更多