TeamCityAPI 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TeamCityAPI --version 0.1.1
NuGet\Install-Package TeamCityAPI -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TeamCityAPI" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TeamCityAPI --version 0.1.1
#r "nuget: TeamCityAPI, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TeamCityAPI as a Cake Addin
#addin nuget:?package=TeamCityAPI&version=0.1.1

// Install TeamCityAPI as a Cake Tool
#tool nuget:?package=TeamCityAPI&version=0.1.1

TeamCity API

Badge
Target Frameworks Targets
Nuget alternate text is missing from this package README image
Downloads alternate text is missing from this package README image
Issues alternate text is missing from this package README image

You can read about TeamCity REST API here.

How to use

TeamCityClient

Create TeamCityClient using your server address:

var client = TeamCityClient("https://buildserver.mycompany.net");

Log in using a token or username and password:

client.UseToken("myToken");
client.UseLoginAndPass("myLogin", "myPassword");

Models

TeamCityClient contains properties, accessing which you can build requests to TeamCity and receive models:

var query = client.Builds;
Builds res = await query.GetAsync();

The GetAsync method returns the Builds entity, which we would get by making a GET request https://buildserver.mycompany.net/app/rest/builds

Locators

In a number of places, you can specify a filter string which defines what entities to filter/affect in the request. This string representation is referred to as locator in the scope of the TeamCity REST API:

var builds = await client.Builds
	.WithLocator(new BuildLocator()
	{
		Agent = new AgentLocator() {Name = "linux-blade-076-vm-13"},
		Count = 50
	})
	.GetAsync();

This query is similar to https://buildserver.mycompany.net/app/rest/builds?locator=agent:(name:linux-blade-076-vm-13),count:50

Includes

You can get children in request:

var query = client.Builds
	.Include(b => b.Build)
		.ThenInclude(x => x.Artifacts)
	.Include(x => x.Build)
		 .ThenInclude(x => x.Agent)

This query is similar to https://buildserver.mycompany.net/app/rest/builds?fields=$short,build($short,artifacts($short),agent($short))

Also there are two include types: short and long. Models can contain simple fields (bool, string, int, etc.) and composite (other models). If we use IncludeType.Short, then only simple fields will be loaded, and composite fields will be null. If we use IncludeType.Long then the composite fields will be loaded as well. Short include:

var query = client.TestOccurrences
                .Include(x => x.TestOccurrence, IncludeType.Short)
                .WithLocator(new TestOccurrenceLocator()
                {
                    Count = 1,
                    Build = new BuildLocator { Id = 156770153}
                });
var tests = await query.GetAsync();

This returns object:

<testOccurrences count="1" href="https://buildserver.mycompany.net/app/rest/testOccurrences?locator=build:(id:156770153),count:1&fields=$short,testOccurrence($short)" nextHref="/app/rest/testOccurrences?fields=$short,testOccurrence($short)&locator=build:(id:156770153),count:1,start:1">
  <testOccurrence id="build:(id:156770020),id:34195" name="TestName" status="UNKNOWN" ignored="true" href="/app/rest/testOccurrences/build:(id:156770020),id:34195"/>
</testOccurrences>

Long include:

var query = client.TestOccurrences
                .Include(x => x.TestOccurrence, IncludeType.Long)
                .WithLocator(new TestOccurrenceLocator()
                {
                    Count = 1,
                    Build = new BuildLocator { Id = 156770153}
                });
var tests = await query.GetAsync();

This returns object:

<testOccurrences count="1" href="https://buildserver.mycompany.net/app/rest/testOccurrences?locator=build:(id:156770153),count:1&fields=$short,testOccurrence($long)" nextHref="/app/rest/testOccurrences?fields=$short,testOccurrence($long)&locator=build:(id:156770153),count:1,start:1">
  <testOccurrence id="build:(id:156770020),id:34195" name="TestName" status="UNKNOWN" ignored="true" href="/app/rest/testOccurrences/build:(id:156770020),id:34195">
    <ignoreDetails>Not implemented</ignoreDetails>
    <test id="-1831283233637679723" name="TestName" href="/app/rest/tests/id:-1831283233637679723"/>
    <build id="156770020" buildTypeId="1234567" number="213.0.20211217.221911-eap09d" status="SUCCESS" state="finished" branchName="refs/heads/net213" defaultBranch="true" href="/app/rest/builds/id:156770020" webUrl="https://buildserver.mycompany.net/viewLog.html?buildId=156770020&buildTypeId=1234567">
      <finishOnAgentDate>20211218T014303+0300</finishOnAgentDate>
    </build>
  </testOccurrence>
</testOccurrences>
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 65,062 5/31/2022
0.1.1 329 1/1/2022
0.1.0 261 12/28/2021