Get test results file from TC using REST API

Is there any way to get Test Results file (in CSV) using REST API? Or any other way to get this file with results using Python?

0
4 comments

While there isn't a way to download the CSV with the REST API alone, you could get the CSV with a Python script. The URL for the CSV file will always be in the same format:

http://<teamcityserver>/get/tests/buildId/<build_id>/<build_configuration_id>_<build_number>-tests.csv

The parameters for each build are retrievable via REST API with the help of the Build Locator. With your Python script, you could collect the parameters from REST API and download the file by constructing the URL.

0

Thank you Eric,

but now I can't fins a way to get

build_configuration_id

Could you please point out how to det it with REST?

0

The Build Configuration ID is the external name for Build Type ID. So you could use a request like this, supplying the Build ID as a locator in this case. It will return the Build ID, Build Configuration ID and the Build Number. 

http://localhost/app/rest/builds?locator=id:<build_id>&fields=build(id,buildTypeId,number)

Using this data, the URL would be constructed like this:

http://<teamcityserver>/get/tests/buildId/<id>/<buildTypeId>_<number>-tests.csv
0

Got it! Thank you for your help!

0

Please sign in to leave a comment.