赞
踩
默认情况下fabric配置参数warn_only=False,即run指令得到的程序结束返回值不为0则引发异常,退出后续的部署。
参考一下代码,有两种方式设置warn_only=True,可实现出错后能继续向下执行
- def deploy():
- with settings(
- warn_only=True
- ):
- run("ls /zz| grep ccc| grep -v fdsfds")
- print "111"
- run("ls /zz", warn_only=True)
- print "222"
输出参考
- D:\code\devops\trunk>fab -f test.py deploy
- [] Executing task 'deploy'
- [127.0.0.1:22] run: ls /zz| grep ccc| grep -v fdsfds
- [127.0.0.1:22] out: ls: cannot access /zz: No such file or directory
- [127.0.0.1:22] out:
-
-
- Warning: run() received nonzero return code 1 while executing 'ls /zz| grep ccc| grep -v fdsfds'!
-
- 111
- [127.0.0.1:22] run: ls /zz
- [127.0.0.1:22] out: ls: cannot access /zz: No such file or directory
- [127.0.0.1:22] out:
-
-
- Warning: run() received nonzero return code 2 while executing 'ls /zz'!
-
- 222
-
- Done.
- Disconnecting from 127.0.0.1:22... done.

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。