【发布时间】:2017-02-16 01:09:46
【问题描述】:
考虑一下:
$ cat test.py
import sys
print "Doing something ..."
sys.exit(1)
$ python test.py
Doing something ...
$ echo $?
1
$ python test.py | tee log # used in Jenkins, but I need to capture rc of 1 as well
Doing something ...
$ echo $?
0
如您所见,如果我将输出通过管道传输到 tee,则无法从 python 脚本中捕获 1 的返回码。有没有办法我可以做到这一点?此代码位于 Jenkins 的 Build->execute shell 部分中。
由于我无法捕获 1 的 rc,因此该行后面的命令继续执行,这是我不希望发生的。
【问题讨论】:
标签: python bash python-2.7 jenkins