2017-03-03 34 views
1

在我的詹金斯的工作,我在下面的方式配置的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") 

然而,在最后一行,当我尝试推到我的仓库,我得到关于存储库的以下错误:

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

什么是错的,我该如何将它推送到存储库?

+0

你试过用--global?试试这个:git config --global user.name“my-user-name” – aicastell

+0

它不是你的git'user.emai/user.name',它是你的'用户名/密码'进行验证。 –

回答

1

您正在寻找credential.username。我不知道的密码,但如果你不喜欢http://username:[email protected]: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步骤的文档。

相关问题