git push偶尔在Jenkins上出现“Device not configured”错误

时间:2016-07-05 12:41:59

标签: git jenkins

我们正在使用Jenkins git plugin在构建之前使用凭据克隆git repo。

在构建结束时,如果成功,我们会执行git push:

BRANCH_TO_PUSH=${GIT_BRANCH/origin\//}
git push origin HEAD:refs/heads/${BRANCH_TO_PUSH}

零星,推送失败,输出如下:

fatal: could not read Username for 'https://git.example.net': Device not configured

如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

当将repo配置为通过HTTPS克隆时,会出现此问题。 如果它只是偶尔发生,则意味着git被配置为使用凭证助手在克隆时存储凭证。

然而,by default the cache is set to 900 seconds (15 minutes)。如果您的构建时间超过此时间,则推送将失败。

要将缓存TTL提升到60分钟,请在Jenkins计算机上运行:

sudo su - jenkins
git config --global credential.helper 'cache --timeout=3600'