Serhiy Serhiy - 4 months ago 130
Python Question

py.test in Jenkins: Build step 'Execute shell' marked build as failure. Where I'm wrong?

I keep receiving an error when run Build. py.tests in jenkins:

jenkins execute shell:

py.test tests || true


it starts. and after it finished I see next log:

> git rev-list 677d82852ecd8edd2c422be1539d8522d6457fec # timeout=10
[web-services tests] $ /bin/sh -xe /tmp/hudson1185445911993953778.sh
+ py.test tests
============================= 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
...
//in the end this error.
Build step 'Execute shell' marked build as failure


Finished: FAILURE

So seems like it run tests but error appears.

jenkins notify Slack:

jenkins BOT [2:06 PM]



web-services tests - #41 Started by user manny (</job/web-services%20tests/41/|Open>)


[2:08]



web-services tests - #41 Success after 1 min 23 sec (</job/web-services%20tests/41/|Open>)
No Tests found.

Answer

Jenkins marks the build success/failed depending on the exit code. 0 is success, else failed.

Exitcode of Py.Test is 0 when there are no errors. When there are 1 or more errors, not 0 (maybe 1, no idea exactly).

Solution:

  • Wrap your call into a seperate shellscript and ignore the exitcode
  • Change Jenkins job to 'your command || true'
Comments