git push sporadically fails on Jenkins with “Device not configured” error

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:

  • How can I limit each file's diff in a git diff output
  • Should a git repo contain all binary & static files needed to deploy?
  • What do the numbers in the “Total” line of git gc/git repack output mean?
  • Keeping track of external git repos merged through `git subtree`
  • How to have meld as git mergetool to only show conflict and not differences?
  • .gitignore doesn't stop changes being tracked in files
  • 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?

  • Git: Finding a deleted file in git, commits not in log
  • GitConfig: bad config for shell command
  • Running git-instaweb on boot
  • Can the runtime of a Heroku app know it's commit id?
  • Trouble connecting to gitosis server
  • Picking the commits to merge with master
  • One Solution collect form web for “git push sporadically fails on Jenkins with “Device not configured” error”

    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 Baby is a git and github fan, let's start git clone.