Fabric -f选项不起作用

时间:2013-07-31 14:18:58

标签: git bash deployment fabric

我已经在我的本地计算机上成功使用了Fabric一段时间了,最​​后有一个体面的部署脚本,我想在git的post-receive钩子中调用它。为了实现这一点,我有以下代码,所有这些代码都经过验证,直到fab命令:

deploy=... # CODE TO DETERMINE IF YOU SHOULD DEPLOY

if [[ $deploy ]] ; then
  TMPFILE="/tmp/$(basename $0).$$.tmp"
  git cat-file blob release:fabfile.py > $TMPFILE
  fab -f $TMPFILE deploy:servername.mycompany.com
  rm $TMPFILE
fi

我已经检查了每一步的方法,我肯定是正确创建了TMPFILE(它包含我的fabfile)。手动运行上面带有/ tmp /中的组合文件的步骤会产生相同的行为。

最糟糕的是,它“提醒”我可以使用-f来指定fabfile ...我就是这样。

1 个答案:

答案 0 :(得分:1)

这是因为它想要一个带有.py的文件。更改您的临时文件以使用此文件扩展名,它将工作。这是一个很有可能让fab想要允许人们使用python样式目录类的工件,例如fabfile/__init__.py将被-f fabfile

选中

此行为示例:

╭─mgoose@Macintosh  ~
╰─$ fab -f tmp.py test
[localhost] local: whoami
mgoose

Done.
╭─mgoose@Macintosh  ~
╰─$ mv tmp.py tmp.py.tmp
╭─mgoose@Macintosh  ~
╰─$ fab -f tmp.py.tmp test

Fatal error: Couldn't find any fabfiles!

Remember that -f can be used to specify fabfile path, and use -h for help.

Aborting.
╭─mgoose@Macintosh  ~
╰─$ cat tmp.py.tmp                                                                                                                                                                                                                        1 ↵
from fabric.api import local, task

@task
def test():
    local("whoami")
相关问题