在使用goreleser将构件发布到GitLab时,操作超时了。

huangapple go评论82阅读模式
英文:

operation timedout while publishing artifacts to gitlab using goreleser

问题

我正在使用golang创建一个简单的CLI应用程序。我正在使用GoReleaser将其发布到Gitlab。我按照https://goreleaser.com/quick-start/中概述的步骤发布更改到gitlab。

我已经生成了一个具有API范围的个人访问令牌。在使用goreleaser发布构件之前,我会标记这些更改并将它们推送。

我总是遇到一个错误,错误消息为release failed after 452.34s error=github/gitlab/gitea releases: failed to publish artifacts: Get "https://PRIVATEGITLABURL/api/v4/projects/PRIVATE_GITLAB_PROJECT/releases/v1%2E0%2E3": dial tcp IP_ADDRESS:443: connect: operation timed out.

我的.gorelease.yml文件如下:

before:
  hooks:
    # 如果你不使用go modules,可以删除这个。
    - go mod tidy
    # 如果你不需要go generate,可以删除这个。
    - go generate ./...
builds:
  - env:
      - CGO_ENABLED=0
    goos:
      - windows
snapshot:
  name_template: "{{ incpatch .Version }}-next"
changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'
# .goreleaser.yml
gitlab_urls:
  api: https://PRIVATE_GITLAB_REPO/api/v4/
  download: https://PRIVATE_GITLAB_REPO
  # 如果你使用自签名证书,请将其设置为true。
  skip_tls_verify: false 

有什么想法吗?我的gitlab版本是GitLab Enterprise Edition 14.1.5-ee。

英文:

I am using golang to create a simple CLI application. I am using GoReleaser to release this to Gitlab. I followed the steps outlined in https://goreleaser.com/quick-start/ to release changes to gitlab.
I have generated a personal access token with API scope. I am tagging the changes and pushing them before I use the goreleaser to publish artifacts.

I always get the error which says release failed after 452.34s error=github/gitlab/gitea releases: failed to publish artifacts: Get "https://PRIVATEGITLABURL/api/v4/projects/PRIVATE_GITLAB_PROJECT/releases/v1%2E0%2E3": dial tcp IP_ADDRESS:443: connect: operation timed out.

My .gorelease.yml file

before:
  hooks:
    # You may remove this if you don't use go modules.
    - go mod tidy
    # you may remove this if you don't need go generate
    - go generate ./...
builds:
  - env:
      - CGO_ENABLED=0
    goos:
      - windows
snapshot:
  name_template: "{{ incpatch .Version }}-next"
changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'
# .goreleaser.yml
gitlab_urls:
  api: https://PRIVATE_GITLAB_REPO/api/v4/
  download: https://PRIVATE_GITLAB_REPO
  # set to true if you use a self-signed certificate
  skip_tls_verify: false 

Any Ideas? My gitlab version is GitLab Enterprise Edition 14.1.5-ee

答案1

得分: 2

首先,请检查是否是由于goreleaser/goreleaser问题1879(“在http(s)代理后使用goreleaser”)引起的,该问题在PR 1885和goreleaser v0.147.0中得到支持:

  • 如果你的GitLab服务器可以通过互联网访问,并且你没有设置HTTP(S)_PROXY环境变量
  • 或者你的GitLab服务器在你的内部网络中,你已经设置了HTTP(S)_PROXY,但忘记了NO_PROXY(在通过https://访问内部网络资源时使用代理)。

Batuhan ApaydınOP的讨论中建议应用gitlab配置

# .goreleaser.yml
release:
  # 默认从origin远程URL中提取,如果是私有托管,则为空。
  # 也可以通过在name字段中设置Gitlab的内部项目ID并将owner字段留空来使用。
  gitlab:
    owner: user
    name: repo. 

OP GrailsTest评论中确认了来自GH讨论的情况:

> 我无法推送我的发布版本,因为我只能通过SSH访问GitLab。
HTTP似乎不起作用。Https从未在我的机器上工作过,可能是因为我没有设置环境变量。
>
> 我的同事可以通过HHTPS和SSH访问GitLab,他可以使其工作。

英文:

Check first if this is because of goreleaser/goreleaser issue 1879 ("
Using goreleaser behind a http(s) proxy "), which is supported since PR 1885 and goreleaser v0.147.0:

  • either your GitLab server is accessible through internet, and you have not set HTTP(S)_PROXY environment variables
  • or your GitLab server is on your intranet, you have set HTTP(S)_PROXY, but forgot the NO_PROXY (to not use the proxy when accessing through https:// an intranet resource).

Batuhan Apaydın suggests in the OP's discussion to apply the gitlab configuration:

# .goreleaser.yml
release:
  # Default is extracted from the origin remote URL or empty if its private hosted.
  # You can also use Gitlab's internal project id by setting it in the name
  #  field and leaving the owner field empty.
  gitlab:
    owner: user
    name: repo. 

The OP GrailsTest confirms, from GH discussion, in the comments:

> I could not push my release as I can only access GitLab via SSH.
HTTP does not seem to work. Https has never worked on my machine, possibly because I have not set environment variables.
>
> I could get this working on my colleagues machine who can access GitLab via HHTPS and SSH.

huangapple
  • 本文由 发表于 2021年9月27日 10:06:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/69340444.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定