Join the DZone community and get the full member experience.Join For Free
TeamCitySharp (TCS) is a simple .net wrapper that will let you interact with a TeamCity server providing you have a login for that system. TeamCity has a REST API but this wrapper will help simplify the calls that that API and deserialize the response for the server into POCOs for you.
In order to get a list of projects on a TeamCity server you would make the request to the following URL:
In order to interact with this, you could use EasyHTTP or HTTP WebRequest. You would set up a connection, specify a content type, give user credentials and then get a response back that you can use. TeamCitySharp has taken care of this for you. The corresponding code to make the same code using TeamCitySharp would be as follows:
There are a number of methods available that will let you get projects, build status’, build types, users, agents, user groups and server information. The project cannot be used to create projects or build types. This is due to the absence of the appropriate calls on the TeamCity REST API. A full list of functionality of the TeamCitySharp API calls can be found in the documentation.
I have created a TeamCitySharp nuget package and you can install that from nuget command line using the comment:
This is very much an early version of the project in order to get user feedback. If you do try it then please do let me know what you don’t like about it and what you feel it would benefit from. Thanks really must go to Hadi Hariri for the idea after I saw YouTrackSharp.
Please feel free to fork the project and send any requests back you feel the project would benefit from. The project is distributed under the MIT license so please adhere to this when using it.
Published at DZone with permission of Paul Stack , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.