How to run certain builds only on specific branches in a TeamCity build chain

Hey everyone,

I have a TeamCity build chain for multiple environments. I’m using a composite build that has a VCS trigger and snapshot dependencies on all environment-specific builds.

The challenge is that some builds should only run for specific branches. For example:

The production build should only run when there’s a push to the main branch.

Other builds (e.g., staging or test) run on their respective branches.

Right now, the composite triggers all dependent builds regardless of branch. I’m looking for a clean way to make builds in the chain branch-specific, ideally without adding separate triggers for each build.

Has anyone set up something similar, or can suggest best practices for branch-based conditional execution in composite build chains?

Thanks in advance!

0
1 comment

Hi!

Have you considered using Conditional Build Dependencies?   

https://www.jetbrains.com/help/teamcity/build-chain.html#Conditional+Build+Dependencies

As an example, you could:

1. On each per-environment build configuration (production, staging, test), add a parameter teamcity.configuration.tags with a descriptive

  value (e.g. production, staging, test).                   

  2. On the composite, add teamcity.build.chain.skipTags (or onlyTags) with the tag list that should be excluded/included for that run.       

  3. Using VCS triggers on the composite, each with a branch filter and its own parameter override. 

Please let me know if this helps.

Thanks!                    

                                                                                                                                              

 

0

Please sign in to leave a comment.