...
List of project features: http://teamcity:8111/httpAuth/app/rest/projects/<projectLocator>/projectFeatures
List features with filtering: http://teamcity:8111/httpAuth/app/rest/projects/<projectLocator>/projectFeatures?locator=<projectFeaturesLocator> ee.g. to find all issue tracker features of GitHub type, use locator "type:IssueTracker,property(name:type,value:GithubIssues)"
Edit features: GETGET/DELETE/PUT http://teamcity:8111/httpAuth/app/rest/projects/<projectLocator>/projectFeatures/<featureId>
...
Also supported:
GET/PUT http://teamcity:8111/httpAuth/app/rest/vcs-roots/<vcsRootLocator>/properties/<property_name>
GET/PUT PUT http://teamcity:8111/httpAuth/app/rest/vcs-roots/<vcsRootLocator>/<field_name>,
where <field_name>
is one of the following: name, shared, project (post project locator to "project" to associate a VCS root with a specific project).
Anchor | ||||
---|---|---|---|---|
|
http://teamcity:8111/httpAuth/app/rest/vcs-root-instances
A "VCS root" is the setting configured in the TeamCity UI, "VCS root instance" is the internal TeamCity entity which is derived from the "VCS root" to perform actual VCS operation.
If the VCS root has no %-references to parametersparameters, a single VCS root corresponds to a single "VCS root instance".
If a VCS root has %-reference to a parameter and the reference resolves to a different value when the VCS root is attached to different configurations or when custom builds are run, a single "VCS root" can generate several "VCS root instances".
...
There are two endpoints dedicated at using in commit hooks from from the version control repositories:
POST
http://teamcity:8111/app/rest/vcs-root-instances/checkingForChangesQueue?locator=<locator>
- returns the list of VCS root instances matched, just like GET http://teamcity:8111/httpAuth/app/rest/vcs-root-instances?locator=<locator>
POST http://teamcity:8111/app/rest/vcs-root-instances/commitHookNotification?locator=<locator> - returns plain-text textual human-readable message on the action performed, HTTP response 202 in case of successful operation
Both perform the same action (put the VCS root instances matched by the <locator>) to the queue for "checking for changes" process and differ only in responses they produce.
Note that since the matched VCS root instances are the same as for .../app/rest/vcs-root-instances?locator=<locator> request and that means that by default only the first 100 are matched and the rest are ignored. If this limit is hit consider tweaking the <locator> to match less instances (recommended) or increase the limit e.g. by adding ",count:1000" to the locator.
...
Build configuration settings: GET/DELETE/PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/settings/<setting_name>
Build configuration parameters: GET/DELETE/PUT
http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/parameters/<parameter_name>
(produces XML, JSON and plain text depending on the "Accept" header, accepts plain text and XML and JSON). The The requests .../parameters/<parameter_name>/name
and .../parameters/<parameter_name>/value
are also supported.
...
Since TeamCity 10, it is possible to disable/enable artifact dependencies and agent requirements:
Disable/enable an artifact dependency PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/artifact-dependencies/<id>/disabled
(put "true" or "false" text as text/plain)
Disable/enable an agent requirement PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/agent-requirements/<id>/disabled
(put "true" or "false" text as text/plain)
...
Read, detach and attach a build configuration from/to a template: GET/DELETE/PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/template
(PUT accepts template locator with "text/plain" Content-Type)
...
List builds: GET http://teamcity:8111/httpAuth/app/rest/builds/?locator=<buildLocator>
Anchor | ||||
---|---|---|---|---|
|
http://teamcity:8111/httpAuth/app/rest/builds/<buildLocator>
(also supports DELETE to delete a build)...
project:<project locator> - limit the list to the builds of the specified project (belonging to any build type directly under the project).
affectedProject:<project locator> - limit limit the list to the builds of the specified project (belonging to any build type directly or indirectly under the project)
buildType:(<buildTypeLocator>) - only the builds of the specified build configuration
Anchor | ||||
---|---|---|---|---|
|
tag:<tag> - since TeamCity 10 get tagged builds. If If a list of tags is specified, e.g. tag:<tag1>, tag:<tag2>, only the builds containing all the specified tags are returned. The legacy tags:<tags> locator is supported for compatibility
...
canceled:<true/false/any> - limit builds by the canceled flag. By default, canceled builds are not included.
failedToStart:<true/false/any> - limit limit builds by the failed to start flag. By default, canceled builds are not included.
running:<true/false/any> - limit builds by the running flag. By default, running builds are not included.
state:running,hanging:true - fetch hanging builds (since TeamCity 10.0)
pinned:<true/false/any> - limit builds by the pinned flag.
Anchor | ||||
---|---|---|---|---|
|
revision:<REVISION> - find builds by revision, e.g. all builds of the given build configuration with the revision: /httpAuth/app/rest/builds?locator=revision:(REVISION),buildType:(id:BUILD_TYPE_ID). See more information below.
agentName:<name> - agent name to return only builds ran on the agent with name specified
...
Get current pin status: GET http://teamcity:8111/httpAuth/app/rest/builds/<buildLocator>/pin
/
(returns "true" or "false" text)
Pin: PUT http://teamcity:8111/httpAuth/app/rest/builds/<buildLocator>/pin
/
(the text in the request data is added as a comment for the action)
Unpin: DELETE http://teamcity:8111/httpAuth/app/rest/builds/<buildLocator>/pin/
(the text in the request data is added as a comment for the action)
(<buildLocator>
here should match a single build only)
...
Cancel a running or a queued build: POST POST the <buildCancelRequest comment='CommentText' readdIntoQueue='false' />
item to the URL of a of a running or a queued build:
...
Stop a running build and readd it to the queue: POST POST the <buildCancelRequest comment='CommentText' readdIntoQueue='true' />
item to the URL of a running build:
...
Get single build's field: GET http://teamcity:8111/httpAuth/app/rest/builds/<buildLocator>/<field_name>
(accepts/produces text/plain) where <field_name>
is one of "number", "status", "id", "branchName" and other build's bean attributes
...
List all agents: GET http://teamcity:8111/httpAuth/app/rest/agents
List all connected authorized agents: GET http://teamcity:8111/httpAuth/app/rest/agents?locator=connected:true,authorized:true
List all authorized agents: GET http://teamcity:8111/httpAuth/app/rest/agents?locator=authorized:true
List all enabled authorized agents: GET http://teamcity:8111/httpAuth/app/rest/agents?locator=enabled:true,authorized:true
Enable/disable an agent: PUT PUT http://teamcity:8111/httpAuth/app/rest/agents/<agentLocator>/enabled
(put "true" or "false" text as text/plain). See an example.
Authorize/unauthorize an agent: PUT http://teamcity:8111/httpAuth/app/rest/agents/<agentLocator>/authorized
(put "true" or "false" text as text/plain)
...
Wiki Markup |
---|
{hidden-data}
Example C# code shared by our users to do REST API calls with NTLM authentication and cookies reuse:
{noformat}
using System;
using System.IO;
using System.Net;
namespace TestingSingleSignOnAuthREST
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetRestResponse("http://teamcity.jetbrains.com", "/app/rest/server"));
Console.ReadLine();
}
public static string GetRestResponse(string server, string requestStr)
{
var cookies = new CookieContainer();
var request = (HttpWebRequest)WebRequest.Create(server + requestStr);
request.Timeout = (int)TimeSpan.FromDays(1).TotalMilliseconds;
request.ContentType = "application/xml";
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
request.CookieContainer = cookies;
var resp = request.GetResponse() as HttpWebResponse;
var reader = new StreamReader(resp.GetResponseStream(), );
return reader.ReadToEnd();
}
}
}
{noformat}
{hidden-data} |
...