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.
The code:
JavaScript
x
16
16
1
# Imports
2
from fabric import Connection
3
from fabric.tasks import task
4
import os
5
6
# Here i pass my local passphrase:
7
kwargs = {'passphrase': os.environ["SSH_PASSPHRASE"]}
8
9
@task
10
def serverdeploy(c, branch="Staging"):
11
con = Connection('myuser@myhost', connect_kwargs=kwargs)
12
with con.cd("/home/user/repository/"):
13
# Activate the virtual environment:
14
with con.prefix("source ENV/bin/activate"):
15
con.run("git pull origin {}".format(branch))
16
The results are:
JavaScript
1
6
1
git@bitbucket.org: Permission denied (publickey).
2
fatal: Could not read from remote repository.
3
4
Please make sure you have the correct access rights
5
and the repository exists.
6
Notes:
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?
Advertisement
Answer
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!