【问题标题】:fatal: could not read Username for, No such device致命:无法读取用户名,没有这样的设备
【发布时间】:2017-03-03 10:48:15
【问题描述】:

在我的 Jenkins 工作中,我通过以下方式配置 git:

sh("git config user.email my.email@google.com")
sh("git config user.name my-user-name")
sh("git tag ${BUILD_NUMBER}")
sh("git push origin --tags")

但是,在最后一行,当我尝试推送到我的存储库时,我收到关于存储库的以下错误:

fatal: could not read Username for 'http://my-git-repo.com:8000': No such device or address

出了什么问题,如何将其推送到存储库?

【问题讨论】:

  • 你试过使用--global吗?试试这个: git config --global user.name "my-user-name"
  • 这不是你的 git user.emai/user.name,而是你的 username/password 进行身份验证。

标签: git jenkins


【解决方案1】:

您正在寻找credential.username。我不知道密码,但如果您不喜欢 http://username:password@my-git-repo.com:8000,请将凭据放入您的 Jenkinsfile,如下所示:

第二种最常见的凭据类型是“用户名和密码” 它仍然可以在environment 指令中使用,但会导致 设置的变量略有不同。

environment {
   SAUCE_ACCESS = credentials('sauce-lab-dev')
}

这实际上会设置3个环境变量:

SAUCE_ACCESS containing <username>:<password>
SAUCE_ACCESS_USR containing the username
SAUCE_ACCESS_PSW containing the password

credentials 仅适用于声明式管道。对于那些 使用脚本管道,请参阅文档 withCredentials一步。

【讨论】:

  • 这是救命稻草。在涉及 withCredentials 的所有其他解决方案都失败后,使用环境凭据以及命令 'git remote set-url origin "https://$@"' 终于让 git push 工作了。
  • 谢谢。虽然是一种解决方法,但它在几天后救了我。
猜你喜欢
  • 2013-09-24
  • 1970-01-01
  • 2019-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-28
  • 2017-03-09
  • 2013-03-22
相关资源
最近更新 更多