I'm trying to automate my deployment with Fabric 2.
When I manually do a git pull through the command line on the remote server everything works fine.
When I try to do the same with my Fabric/Invoke script it does not allow me to pull.
It does though allow me to do git status and other commands.
# Imports
from fabric import Connection
from fabric.tasks import task
import os
# Here i pass my local passphrase:
kwargs = {'passphrase': os.environ["SSH_PASSPHRASE"]}
@task
def serverdeploy(c, branch="Staging"):
con = Connection('myuser@myhost', connect_kwargs=kwargs)
with con.cd("/home/user/repository/"):
# Activate the virtual environment:
with con.prefix("source ENV/bin/activate"):
con.run("git pull origin {}".format(branch))
The results are:
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I don't even get asked for a passphrase while doing the pull.
I have tried doing the pull without activating the environment but that didn't work either.
What could possibly be the problem?
Thanks in a advance for taking the time!
Please place con.run("git pull origin {}".format(branch))
outside the with con.prefix("source ENV/bin/activate"):
.
Your code has nothing to do with the interpreter or the virtual env! Try that and it should works!
Thank you, that was step one. Step two was adding pty=True on the git command