How to run all the builds in a row in the Teamcity project with the same checkout branch

506 Views Asked by At

I have a Teamcity Project with VCS Root configured like this:

  • Default branch: develop
  • Branch specification: +:refs/heads/(*)

I hope it means I may pass any branch name and it will be processed successfully. The project contains two builds. Let it be STEP_A and STEP_B.

STEP_B has a trigger finishBuildTrigger:

{ buildType = "${STEP_A.id}" branchFilter = "+:*" }

which means it will starts after the STEP_A ends.

I want to run all the builds via REST API. I do POST /app/rest/buildQueue with parameter branchName = "feature_222".

Ok, I see that STEP_A successfully starts with feature_222 branch checkout. After it ends STEP_B starts to run BUT with develop branch checkout. Of course, it is not a desirable behavior.

What should I do to fix that?

1

There are 1 best solutions below

3
Yan Sklyarenko On BEST ANSWER

I would re-configure this pipeline to rely on the snapshot dependency rather than on the finish build trigger. So, follow the steps below:

  • Remove (or just disable to try it out) the finishBuildTrigger
  • Add a new snapshot dependency from Step B to Step A (in the screenshot below, it is configured from Deploy configuration to Build)
  • Trigger the build of Step B with the REST API

This is how it looks like:

enter image description here

According to the docs:

Build configurations linked by a snapshot dependency can optionally use revisions synchronization to ensure the same snapshot of the sources.

To tell it short, the snapshot dependency is the mechanism to enforce the same version (snapshot) of the sources being built by the build chain.

See the official documentation for more details.