git 致命:无法读取用户名,没有这样的设备
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42576857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
fatal: could not read Username for, No such device
提问by octavian
In my Jenkins job, I am configuring git in the following way:
在我的 Jenkins 工作中,我按以下方式配置 git:
sh("git config user.email [email protected]")
sh("git config user.name my-user-name")
sh("git tag ${BUILD_NUMBER}")
sh("git push origin --tags")
However, on the last line, when I try to push to my repository, I get the following error about the repository:
但是,在最后一行,当我尝试推送到我的存储库时,我收到有关存储库的以下错误:
fatal: could not read Username for 'http://my-git-repo.com:8000': No such device or address
What's wrong and how can I make it push to the repository?
出了什么问题,如何将其推送到存储库?
回答by Cees Timmerman
You're looking for credential.username
. I don't know about the passphrase, but if you dislike http://username:[email protected]:8000
then put the credentials in your Jenkinsfilelike so:
您正在寻找credential.username
. 我不知道密码短语,但如果您不喜欢,http://username:[email protected]:8000
请将凭据放入您的Jenkinsfile 中,如下所示:
The second most common type of Credentials is "Username and Password" which can still be used in the
environment
directive, but results in slightly different variables being set.environment { SAUCE_ACCESS = credentials('sauce-lab-dev') }
This will actually set 3 environment variables:
SAUCE_ACCESS containing <username>:<password> SAUCE_ACCESS_USR containing the username SAUCE_ACCESS_PSW containing the password
credentials
is only available for Declarative Pipeline. For those using Scripted Pipeline, see the documentation for thewithCredentials
step.
第二种最常见的凭据类型是“用户名和密码”,它仍然可以在
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
步骤的文档 。