Skip to end of metadata
Go to start of metadata

In addition to the commands described here, there is a REST API that you can use for certain operations. When available, using REST API is a preferred way over one described here.

The examples below assume that your server web UI is accessible via http://teamcity.jetbrains.com:8111/ URL.

The TeamCity server supports basic HTTP authentication allowing users to access certain web server pages and perform actions from various scripts. Please consult the manual for the client tool/library on how to supply basic HTTP credentials when issuing a request.

Use the valid TeamCity server username and password to use basic HTTP authentication. Appropriate user permissions  are required to perform the actions.

Icon

You may want to configure the server to use HTTPS as username and password are passed in insecure form during basic HTTP authentication.

To force using a basic HTTP authentication instead of redirecting to the login page if no credentials are supplied, prepend a path in the usual TeamCity URL with "/httpAuth". For example:

The HTTP authentication can be useful when downloading build artifacts and triggering a build.

If you have Guest user enabled, it can be used to perform the action too. Use "/guestAuth" before the URL path to perform the action on Guest user behalf. For example:

Icon

Please make sure the user used to perform the authentication (or Guest user) has appropriate role to perform the necessary operation.

Triggering a Build From Script

Since TeamCity 8.1 the recommended and more feature-rich way to trigger a build is via REST API. The approach below will be removed in the future TeamCity versions.

To trigger a build, send the HTTP POST request for the URL: http://<server address>/httpAuth/action.html?add2Queue=<build configuration ID> performing basic HTTP authentication.

Some tools (for example, Wget) support the following syntax for the basic HTTP authentication:

Example:

You can trigger a build on a specific agent passing additional agentId parameter with the agent's Id. You can get the agent Id from the URL of the Agent's details page (Agents page > <agent name>). For example, you can infer that agent's Id equals "2", if its details page has the following URL:

To trigger a build on two agents at the same time, use the following URL:

To trigger a build on all enabled and compatible agents, use "allEnabledCompatible" as agent ID:

Triggering a Custom Build

TeamCity allows you to trigger a build with customized parameters. You can select particular build agent to run the build, define additional properties and environment variables, and select the particular sources revision (by specifying the last change to include in the build) to run the build with. These customizations will affect only the single triggered build and will not affect other builds of the build configuration.

To trigger a build on a specific change inclusively, use the following URL:

modificationId — modification/change internal id which can be obtained from the web diff url.

To trigger a build with custom parameters (system properties and environment variables), use:

Where <full property name> is a full property name with system./env. prefix or no prefix to define configuration parameter.
Please note that previous TeamCity versions used different syntax for this action. That syntax is still supported for compatibility reason, though.

To move build to the top of the queue, add the following to the query string

  • &moveToTop=true

To run a personal build, add &personal=true to the query string.

To run a build on a feature branch:

7 Comments

  1. Any support yet for actually creating projects & builds via HTTP? I've just raised a feature request for this as it would be very handy to be able to script the configuration of projects/builds.

    1. Right now this could be done via plugin only. I.e. you can write a plugin which will provide necessary HTTP interface and create projects using TeamCity open API.

  2. Also some notes on "undocumented" (read: can change in any release without extra notice) abilities:
    Apply VCS label for a build.

    Then see Changes tab on build results for the result.

    Set TeamCity tag for a build (see also REST API):

    Pin a build in TeamCity:

    Stop/Cancel a build:

    Pause a Build Configuration:

    (pass pause=false to activate Build Configuration)

    1. Since 8.0, the stop/cancel build URL requires an additional parameter operationKind.
      Its values:
      1 — remove from the queue
      2 — stop a running build
      3 — delete a finished build

  3. I used &rebuildDependencies and &buildComment. Are they considered to be undocumented? (i.e. can I rely that they both will exist in future)?

    1. We consider all such requests undocumented.

      They will exist in future, but a syntax may be changed.

      At some point we'll add this functionality to REST API, so it becomes official and documented feature. Vote and watch for TW-14941.

  4. How do I add a build with a specific VCS revision?