Symptoms
The information about the build that is currently running is requested from within the same build using the REST API. As an example, after the tests are finished, the number of failed, passed, etc. tests is requested in the next build step with the following REST API request:
GET /app/rest/builds?locator=id:<buildID>&fields=build(id,testOccurrences(count,failed,ignored,muted,newFailed,passed))
However, the response doesn't contain any tests, even though they are already finished on the build agent:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><builds><build id="<BuildId>"/></builds>
Cause
There is a race condition between the build agent reporting the build information (the tests results in the above example) to the server and the request.
If the request is made right away, the agent may not have yet reported the expected information to the server, and the build information provided in the response may not be actual.
Resolution
To work around this race condition, adding some wait time to the script before sending the request (with the sleep command or its analog) is recommended. The exact time to wait may be different from one case to another, so it's recommended to experiment with it to find the most suitable value.
Comments
0 comments
Please sign in to leave a comment.