0

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

jenkins execute shell:

#!/bin/sh
py.test tests || true

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

   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 notify Slack:

web-services tests - #44 Back to normal after 19 min (</job/web-services%20tests/44/|Open>)
No Tests found.

No tests found. How to fix it?

Serhiy
  • 1,893
  • 9
  • 30
  • 48

3 Answers3

1

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'
RvdK
  • 19,580
  • 4
  • 64
  • 107
  • thank you.I am very new in it. Put like this: py.test tests || true ??? could you write code what I should use? – Serhiy Aug 02 '16 at 11:03
  • Depends on Windows/Linux, but that's what I found, I used the seperate shellscript for tests so I had them in VersionControl. For Linux: http://stackoverflow.com/questions/22814559/how-when-does-execute-shell-mark-a-build-as-failure-in-jenkins – RvdK Aug 02 '16 at 11:10
0

Run the same test manually (outside of Jenkins) and check the error there. Could be a problem is test collection, or just a test failure itself.

Also: please post full logs so we can better check what is going on

Davy
  • 1,720
  • 1
  • 19
  • 42
0

From the log, we can see that the python script has failed

collected 99 items / 4 errors

And from Jenkins point of view, if any error is encountered, it will give failure as Jenkins uses /bin/sh -xe by default.

So by adding the #!/bin/sh before calling the python script might help in resolving this issue :

    #!/bin/sh
    py.test tests
sca
  • 39
  • 2