Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does TeamCity support build steps that execute other TeamCity builds?

Tags:

teamcity

Using TeamCity, I've set up several builds in a project. Most of the time I want to run each build as a standalone. However, sometimes I want to execute several builds with the same set of parameters. The builds all use the same template, so all of their parameters could, theoretically, be supplied by a single build.

I can't find anything in the documentation that says this is possible, but it seems like it should be. (searching for "execute builds from another build in teamcity" gives me plenty of documentation on build dependencies, but not what I'm looking for)

I know I can manually queue up all of my builds, but that would require re-entering the same parameters each time.

Does TeamCity support build steps that execute other TeamCity builds? If so, How?

like image 607
Peach Avatar asked May 24 '16 14:05

Peach


People also ask

What are build steps in TeamCity?

In Build Steps, click Auto-detect build steps, and then select the proposed steps you want to add to the current build configuration. You can change their settings afterwards. When scanning the repository, TeamCity progressively searches for project files on the two highest levels of the source tree.

What is build chain in TeamCity?

A build chain is a sequence of builds interconnected by snapshot dependencies. Sometimes the build chain is called a "pipeline". Parts of a build chain linked with snapshot dependencies with enabled revisions synchronization use the same snapshot of the sources.


2 Answers

Not exactly. However, in TeamCity you can have a build chain (builds the invoke other dependant builds) by adding a snapshot dependency.

If you add a snapshot dependency on another build configuration, then you can access all its defined parameters and even source and artefacts.

like image 131
Bishoy Avatar answered Oct 24 '22 13:10

Bishoy


I achieve this by calling the TeamCity REST API:

  1. Add a new step at the end of your build, using Command Line runner

  2. Do curl

    curl -X POST -H "Authorization: Bearer %TeamCityToken%"
    --header "Content-Type:application/xml"
    -d" <buildType id="Remote Deploy"/> <property name="tag" value="%NewVersion%"/> "
    http://teamcity.example.com/app/rest/buildQueue

You will need to change:

TeamCityToken to your access token, refer to this page to create one: https://www.jetbrains.com/help/teamcity/rest/teamcity-rest-api-documentation.html#REST+Authentication

Build type id "Remote Deploy" to your build type id.

The properties to whatever you need.

And, of cause, the teamcity url.

like image 41
Lawrence Ching Avatar answered Oct 24 '22 14:10

Lawrence Ching