py.test 在 Jenkins 中:未在 slack 中找到测试。我哪里错了?
py.test in Jenkins: No tests found in slack. Where I'm wrong?
我在 运行 构建时不断收到错误消息。 py.tests 在詹金斯中:
詹金斯执行 shell:
#!/bin/sh
py.test tests || true
开始了。完成后我看到下一条日志:
Started by user manny
Building in workspace /var/lib/jenkins/workspace/web-services tests
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://example.git # timeout=10
Fetching upstream changes from https://example.org/m.git
...
...
[web-services tests] $ /bin/sh /tmp/hudson1759686215204688979.sh
============================= test session starts ==============================
platform linux -- Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /var/lib/jenkins/workspace/web-services tests/tests, inifile:
plugins: asyncio-0.3.0
collected 99 items / 4 errors
tests/bll/test_action_manager.py ...... //here goes list of tests
...
===== 3 failed, 75 passed, 1 skipped, 20 xfailed, 4 error in 76.85 seconds =====
Finished: SUCCESS
jenkins 通知 Slack:
web-services tests - #44 Back to normal after 19 min (</job/web-services%20tests/44/|Open>)
No Tests found.
未找到测试。如何解决?
运行 手动进行相同的测试(在 Jenkins 之外)并检查那里的错误。
可能是测试集合有问题,或者只是测试失败本身。
另外:请 post 完整的日志,以便我们更好地检查发生了什么
Jenkins 根据退出代码标记构建 success/failed。 0 表示成功,否则失败。
如果没有错误,Py.Test 的退出代码为 0。当有 1 个或多个错误时,不是 0(可能是 1,具体不知道)。
解决方案:
- 将您的调用包装到单独的 shellscript 中并忽略退出代码
- 将 Jenkins 作业更改为
'your command || true'
从日志中,我们可以看到 python 脚本失败了
collected 99 items / 4 errors
并且从 Jenkins 的角度来看,如果遇到任何错误,它将失败,因为 Jenkins 默认使用 /bin/sh -xe
。
因此,在调用 python 脚本之前添加 #!/bin/sh
可能有助于解决此问题:
#!/bin/sh
py.test tests
我在 运行 构建时不断收到错误消息。 py.tests 在詹金斯中:
詹金斯执行 shell:
#!/bin/sh
py.test tests || true
开始了。完成后我看到下一条日志:
Started by user manny
Building in workspace /var/lib/jenkins/workspace/web-services tests
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://example.git # timeout=10
Fetching upstream changes from https://example.org/m.git
...
...
[web-services tests] $ /bin/sh /tmp/hudson1759686215204688979.sh
============================= test session starts ==============================
platform linux -- Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1
rootdir: /var/lib/jenkins/workspace/web-services tests/tests, inifile:
plugins: asyncio-0.3.0
collected 99 items / 4 errors
tests/bll/test_action_manager.py ...... //here goes list of tests
...
===== 3 failed, 75 passed, 1 skipped, 20 xfailed, 4 error in 76.85 seconds =====
Finished: SUCCESS
jenkins 通知 Slack:
web-services tests - #44 Back to normal after 19 min (</job/web-services%20tests/44/|Open>)
No Tests found.
未找到测试。如何解决?
运行 手动进行相同的测试(在 Jenkins 之外)并检查那里的错误。 可能是测试集合有问题,或者只是测试失败本身。
另外:请 post 完整的日志,以便我们更好地检查发生了什么
Jenkins 根据退出代码标记构建 success/failed。 0 表示成功,否则失败。
如果没有错误,Py.Test 的退出代码为 0。当有 1 个或多个错误时,不是 0(可能是 1,具体不知道)。
解决方案:
- 将您的调用包装到单独的 shellscript 中并忽略退出代码
- 将 Jenkins 作业更改为
'your command || true'
从日志中,我们可以看到 python 脚本失败了
collected 99 items / 4 errors
并且从 Jenkins 的角度来看,如果遇到任何错误,它将失败,因为 Jenkins 默认使用 /bin/sh -xe
。
因此,在调用 python 脚本之前添加 #!/bin/sh
可能有助于解决此问题:
#!/bin/sh
py.test tests