9
votes

I want to accomplish following via teamcity in my CI box.

Master branch commit : Build and Release
Beta branch commit: Build and Release to Crashlytics
All other commits to any other branch: Build

(side note since most of our development branches may or may not contain a prefix, it makes it difficult to use "feature-*" branch naming)

Following this question Select Git branch for TeamCity Build

I have created a Configuration Parameters in my project settings

enter image description here

and then

my VCS root settings

enter image description here

Then I created a build template

enter image description here

When I created builds I made sure branch name is correct

enter image description here

I have also tried to edit Triggers

enter image description here

How ever this is not working because when I push a commit to Beta branch

I think because of ref/heads/* default build is running all the branches

and Beta and Master displays "Pending"

enter image description here

How can I correct this?

2

2 Answers

1
votes

I solved the problem by talking to other developers and making sure that all development branches uses a prefix, in this case XAAI-

then in my VCS root settings

enter image description here

for triggers in each build configuration I make sure it only is triggered when that branch is checked in.

for example for QA (Betabuild)

enter image description here

this is the tricky part , for Development branches I had to give an empty parameter, I dont know why (maybe because something needs to check default branch which is supposed to be ref/heads/) but whatever the reason it is working.*

enter image description here

and then finally whole thing looks like this

enter image description here

That pending thing is still annoying but , I think at least it is working as I envisioned now.

0
votes

If you want your builds to only trigger automatically when the default branch is pushed to, you can add a branch filter to the trigger like so +:<default>.

This is dependent on the assumption that you have setup the %BranchName% parameter in each build configuration correctly. IE, for your Default build, make the %BranchName% parameter = master.

As a side note, you will still see all pending changes for each branch, but the trigger will only run when you push to your default build if you add the branch filter. If you want to get rid of the pending changes for each branch, you'll need to setup your vcs root specfic for each configuration to filter out the branches all together.