How to get all the build number of a specific build from TeamCity
I need to get from TeamCity all the build number for a specific configuration (identified by his buildTypeId) with the state (succesfull or failed). Is there a simple way to do that ?
I tried to get the data from TeamCity database (we use SQL Server Express) or the data folder, but I could not find it. According to my search I can do that only with the TeamCity API, but I would like to avoid making a TeamCity plugin just for that. In fact, I won't do a plugin in such case. Simply set the data in some table or file that during the build itself (we use NAnt).
Is there any other way to get such data ?
My goal is to get all succesfull build with thier corresponding build number and import them in TFS (with a GlobalList) to be able to use them in TFS WorkItem field.
Please sign in to leave a comment.
Please describe your case in more detail. Do you mean buildId? Build Number? Build Type Id?
If you need buildId, try ${teamcity.agent.dotnet.build_id} property in NAnt. Note, that this is internal property and it may be changed in future releases of TeamCity.
My question is not relative to the build process at all. My goal is to made a script(or anything else) which will import into TFS the last 20 correct succesfull build number of a specific TeamCity configuration. This script will run on a daily basis. So is there a way to get such data from TeamCity (either programmatically, directly fron the database or from data folder) ?
Please take a look to TeamCity REST api plugin.
http://confluence.jetbrains.net/display/TW/REST+API+Plugin
I believe this plugin provide necessary information.
I saw it already, but I want to avoid making a plugin just for that. I would prefer a way to get this data from TeamCity dabatase or conf folder. But thank anyway.
You do no need to write a plugin for TeamCity to use REST API.
Try opening an URL like:
http://teamcity.server.url/httpAuth/app/rest/buildTypes/id:bt284/builds?status=SUCCESS&count=20
where bt284 is buildTypeId of the build configuraiton you are interested in.
The request will be XML with the list of the builds.
You can then use a tool like curl to execute the request from a command line, parse the result and list the necessary build numbers.
It's exactly what I need ! I clearly did not correctly understood what REST API is. Thank to both of you for your help.
Just for the record, and to give a concrete sample, here the code which I used to get the information though REST API which PowerShell: