Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Fabric - How to provide git credentials?

Tags:

git

python

fabric

I have been using python fabric for deploying my Django projects. Over the time the deployment has spanned multiple servers. The Fab script downloads code from git on the server and deploys. And it does that for every server.

My git access is through email and password. How can i avoid entering my email & password for each server every time i deploy? Git credentials cache doesn't seem to help.

I would like to avoid using SSH key based authentication for GIT.

like image 422
G.D. Singh Avatar asked Mar 11 '26 03:03

G.D. Singh


1 Answers

For people coming to this question with fabric 2, I have found the following works:

from invoke import Responder

git_watchers = [
  Responder(pattern = r"Username for .*", response="git_user\n"), 
  Responder(pattern = r"Password for .*", response="git_password\n") ]

ctxt.run("git fetch", pty=True, watchers=git_watchers)

Hope this helps.

like image 56
Diego-MX Avatar answered Mar 12 '26 16:03

Diego-MX