jenkins 中通过 python builder 执行 shell

jenkins 构建报错日志

[UI_Monitor_python] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/shiningpanda8557500049733673903.sh
+ py.test UI.py --maxfail=3 --pastebin=all --html=../output/html/report.html
/Users/Shared/Jenkins/tmp/shiningpanda8557500049733673903.sh: line 2: py.test: command not found

直接在终端上执行又是好的

▶ py.test -v
============================= test session starts ==============================
platform darwin -- Python 2.7.11, pytest-3.0.3, py-1.4.31, pluggy-0.4.0 -- /usr/local/opt/python/bin/python2.7
cachedir: .cache
rootdir: /Users/zengyuanchen, inifile: 
plugins: html-1.10.1

在 jenkins 配置了 PATH 路径也不行,本地环境变量 PATH 是正常的

▶ echo $PATH
/Users/xxx/.nvm/versions/node/v5.10.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/ci-tools/apache-ant-1.9.7/bin:/ci-tools/apache-jmeter-3.0/bin:/ci-tools/apache-maven-3.3.9/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/bin:/ci-tools/apache-ant-1.9.7/bin:/ci-tools/apache-jmeter-3.0/bin:/ci-tools/apache-maven-3.3.9/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/bin

执行 which py.test 查看命令路径

▶ which py.test
/usr/local/bin/py.test

现在不知道问题在哪了


↙↙↙阅读原文可查看相关链接,并与作者交流