1

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?

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
kirill.login
  • 899
  • 1
  • 13
  • 28

1 Answers1

0

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.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • It works, thank you. But what if project has not a simple dependency chain A -> B -> C? What if it looks like: A -> B, A -> C, A -> D. Should I make a three REST API calls to starts all the builds? I just want to tell the project "RUN" once. And It should fisrt run A, and then B,C,D in parallel. – kirill.login Nov 05 '19 at 11:19
  • Well, that's a bit trickier, of course. Making three API calls doesn't sound optimal. You can make a "service" build configuration called E and make it snapshot-dependent on B, C, and D. It won't do anything useful itself - will just be there to trigger this dependency diamond. Although, it's still a trade-off and is more a workaround than a out-of-the-box solution. :) – Yan Sklyarenko Nov 05 '19 at 11:27
  • Yeah, this is a solution. But it still looks weird. I am more familiar with the Jenkins. And with the Jenkins I would just create a script with a checkout step in the first place. And no more headache. All the following steps will work with the checkout result. And all you need is to run the Job with the "branch" (or something) parameter. – kirill.login Nov 05 '19 at 11:35