git clone 在本地工作,但在 GitLab Runner 中不起作用。

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

git clone works locally but not from gitlab runner

问题

我今天早上在我的GitLab CI/CD上遇到了奇怪的问题。在身份验证步骤上,Git克隆操作失败了。
错误信息如下:

remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://gitlab.iselection.com/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'https://gitlab.xxx.com/xxx/'

以下是YAML文件:

variables:
  GIT_SSL_NO_VERIFY: "true"
  TOKEN_NAME: certificate
  TOKEN_VALUE: "xxx"
image: alpine:latest

before_script:
    - apk add git curl openssl openjdk11 bash ca-certificates
    - git clone https://$TOKEN_NAME:$TOKEN_VALUE@gitlab.xxx.com/xxx

因此,我正在使用在我想克隆的存储库中定义的令牌,当我在我的本地机器上运行相同的命令时,它可以顺利工作。

接下来我可以检查什么或者我可以做什么?

谢谢

编辑:其他失败的测试

  • 在我的用户上创建PAT(从我的机器克隆可以正常工作,但从Gitlab CICD流水线中不行
  • 创建部署令牌(从我的机器克隆可以正常工作,但从Gitlab CICD流水线中不行
英文:

I have a weird behavior since this morning on my gitlab CI/CD. The git clone fails on the authentication step.
The error is as follow

remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://gitlab.iselection.com/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'https://gitlab.xxx.com/xxx/'

Here is the yaml file

variables:
  GIT_SSL_NO_VERIFY: "true""
  TOKEN_NAME: certificate
  TOKEN_VALUE: "xxx"
image: alpine:latest

before_script:
    - apk add git curl openssl openjdk11 bash ca-certificates
    - git clone https://$TOKEN_NAME:$TOKEN_VALUE@gitlab.xxx.com/xxx

So I am using a token defined in the repo I want to clone and when running the same command from my local machine, it works smoothly.

What can I check next or what can I do ?

Thx

edit: other failing tests

  • creation of a PAT on my user (clone works from my machine but not from the Gitlab CICD pipeline)
  • creation of a deploy token (clone works from my machine but not from the Gitlab CICD pipeline)

答案1

得分: 1

我们遇到了同样的问题,似乎与最新的cURL版本(8.2.0)有关。我们将我们的libcurlcurl版本固定在8.0.1上,这解决了我们遇到的问题。

在我们的Alpine Docker容器中,我们更新为使用:

apk add --update --upgrade --no-cache libcurl=8.0.1-r0 curl=8.0.1-r0 --repository=https://dl-cdn.alpinelinux.org/alpine/v3.14/main
英文:

We ran into this same issue and it appears to be related to the latest cURL version (8.2.0). We pinned our libcurl and curl versions to 8.0.1 and it fixed the issue we had.

In our Alpine docker container, we updated to use:

apk add --update --upgrade --no-cache libcurl=8.0.1-r0 curl=8.0.1-r0 --repository=https://dl-cdn.alpinelinux.org/alpine/v3.14/main

答案2

得分: 1

有一个问题是在目前的alpine最新版本中出现了curl的问题。尝试使用Alpine版本3.11.13

image: alpine:3.11.13
英文:

There is an issue with curl on the latest version of alpine right now. Try using Alpine version 3.11.13

image: alpine:3.11.13

huangapple
  • 本文由 发表于 2023年7月20日 16:41:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76728108.html
匿名

发表评论

匿名网友

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

确定