当git在远程服务器上拉时,Fabric 2自动执行部署错误。找不到存储库

我正在尝试使用Fabric 2自动化部署。

当我手动在远程服务器上通过命令行执行git pull时,一切正常。

当我尝试对Fabric / Invoke脚本执行相同操作时,它不允许我拉动。

它的确允许我执行git status和其他命令。

代码:

# 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))

结果是:

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.

注意:

在拉动时我什至没有被要求输入密码。

我尝试在不激活环境的情况下进行拉动,但这也不起作用。


可能是什么问题?

预先感谢您抽出宝贵的时间!

lz245548622 回答:当git在远程服务器上拉时,Fabric 2自动执行部署错误。找不到存储库

请将con.run("git pull origin {}".format(branch))放在with con.prefix("source ENV/bin/activate"):之外。

您的代码与解释器或虚拟环境无关!试试看,它应该可以工作!

,

最可能的问题是,您作为登录用户登录的用户具有适用于bitbucket.org的ssh密钥设置,但是结构连接用户却不同。您可以通过以下两个命令来测试设置是否正确:作为Fabric连接用户的方式为:

ssh -T git@bitbucket.org
ssh -T -i /path/to/private_key git@bitbucket.org

为了解决此问题,请将私钥复制到/home/myuser/.ssh目录,并将bitbucket.org的ssh配置项添加到/home/myuser/.ssh/config

Host bitbucket.org
  IdentityFile /path/to/private_key
本文链接:https://www.f2er.com/2722596.html

大家都在问