无法读取“https://gitlab.com”的用户名:Gitlab CI 上没有此类设备或地址

问题描述 投票:0回答:3

我正在尝试将 gitlab CI 集成到我的节点项目上,我有 SSH 访问权限,但我的脚本因错误而停止:

fatal: could not read Username for 'https://gitlab.com': No such device or address
debug2: channel 0: written 83 to efd 7
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 6 efd 7 [write])
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/7 sock -1 cc -1)
debug3: send packet: type 1
debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
debug1: fd 2 clearing O_NONBLOCK
Transferred: sent 3560, received 3156 bytes, in 0.7 seconds
Bytes per second: sent 5437.2, received 4820.2
debug1: Exit status 1
Cleaning up file based variables
00:01 ERROR: Job failed: exit code 1

我已经尝试过了

git config --global credential.helper store

git config --global user.password "myPassword"

git config --global user.email "myEmail"
  • 我发现 git 不提供无交互选项...

  • 图片:节点:最新的 debian 服务器

  • 我的 ssh 凭据和访问权限正常

  • 当我直接在服务器上测试时,它仍然要求我提供连接信息

  • 这是一个私人存储库

node.js git deployment continuous-integration gitlab-ci
3个回答
27
投票

尝试使用以下命令更改服务器上的存储库来源:

git remote set-url origin https://username:[email protected]/path_to_your_repo/repo.git

这样在 git pull 或 git push 时就不会要求提供凭据


0
投票

对于那些使用 .gitmodules 以及可能是私有存储库以及 gitlab 15.11.11-ee 或类似版本并且可能使用 https 并尝试让 gitlab 运行程序检查子模块的人:

如果您的 .gitmodules url 中包含projectxxx而不是projectxxx.git,则可能会出现此错误 - 使用各种其他凭据设置它会正常工作,但是当 gitlab CI 运行它时,您将有一个日志条目

"warning: redirecting to ..." 

它将 .git 添加到项目名称中以修复您的 URL 并成功找到该项目 - 但无法将 gitlab-ci-token 传递到新的 URL 请求。因此它试图在没有任何身份验证的情况下获取该项目,但失败了

因此请检查您是否有该日志条目,如果有,请通过编辑 .gitmodules 文件并将 .git 添加到项目 URL 的末尾并签入来修复

这曾经在 2023 年第 3 季度的项目 URL 中没有 .git 的情况下为我工作,但现在不行了,所以是由某处引入的错误


-1
投票

这个解决方案对 gitlab 的我有用https://wahlnetwork.com/2020/08/11/using-private-git-repositories-as-terraform-modules/。总之,我设置了一个令牌,并从管道执行了 git config 命令

© www.soinside.com 2019 - 2024. All rights reserved.