我的环境基于带有vagrant或docker的窗口作为实际环境。我想建立一种直接从Windows直接部署内容的快速方法,但如果我可以运行它会很棒
fab deploySomething
例如,这将在本地构建反应应用程序,提交并推送到服务器。但是我被困在当地的位置。
我的设置是:Windows 10 Fabric 2 Python 3
我有一个fabfile.py设置了一个简单的测试:
from fabric import Connection, task, Config
@task
def deployApp(context):
config = Config(overrides={'user': 'XXX', 'connect_kwargs': {'password': 'YYY'}})
c = Connection('123.123.123.123', config=config)
# c.local('echo ---------- test from local')
with c.cd('../../app/some-app'):
c.local('dir') #this is correct
c.local('yarn install', echo=True)
但我刚刚得到:
'yarn' is not recognized as an internal or external command, operable program or batch file.
你可以用几乎任何东西替换'yarn',我不能用本地手动运行的命令运行。通过调试,我得到的是:
DEBUG:invoke:Received a possibly-skippable exception: <UnexpectedExit: cmd='cd ../../app/some-app && yarn install' exited=1>
这不是很有帮助......有人遇到过这个吗?我可以找到的带有结构的本地命令的任何示例似乎都是指旧的1.X版本
要运行本地命令,请从context
而不是连接中运行它们。 n.b.,这会让你跌到invoke
水平:
from fabric import task
@task
def hello(context):
with context.cd('/path/to/local_dir'):
context.run('ls -la')
也就是说,问题可能是您需要yarn
的完全限定路径,因为您的环境路径尚未获取。