git push在Jenkins上偶尔失败,“Device not configured”(设备未配置)错误 [英] git push sporadically fails on Jenkins with "Device not configured" error

查看:612
本文介绍了git push在Jenkins上偶尔失败,“Device not configured”(设备未配置)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 Jenkins git插件克隆git repo,凭证,在构建之前。



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

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


偶尔,推送失败,输出如下: pre> 致命:无法读取'https://git.example.net'的用户名:未配置设备

这个问题如何解决? 解决方案

配置为通过HTTPS进行克隆。
如果它偶尔发生,这意味着git被配置为使用凭证助手在克隆时间存储凭证。



然而,默认情况下,缓存设置为900秒(15分钟)。如果您的构建时间超过此时间,推送将失败。



要将缓存TTL提高到60分钟,请在Jenkins机器上运行:

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


We are using Jenkins git plugin to clone git repo, with credentials, before the build.

At the end of the build, if it is successful, we do git push:

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

Sporadically, the push fails with the following output:

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

How can this issue be solved?

解决方案

The issue happens when the repo is configured to be cloned over HTTPS. If it only happens sporadically, it means that git is configured to use credential helper to store the credentials at clone time.

However, by default the cache is set to 900 seconds (15 minutes). If your build takes longer than that, the push will fail.

To raise the cache TTL to 60 minutes run this on your Jenkins machine:

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

这篇关于git push在Jenkins上偶尔失败,“Device not configured”(设备未配置)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆