How to change the branch being built in TeamCity - teamcity

How do I change the branch being built in TeamCity. It seems like the master is the only branch I can use:

Disclaimer: I'm fairly new to TeamCity.
I click on project which will show me my repository.
Clicking on both the drop down arrows shows me the branches of my repository
Click on the branch you want to build. Then you can run the build

Related

Start build on old branch without new commit

Context
I have a project absed on a vcs root with the wildcard branch filter (+:*), meaning that it will trigger a build on every possible modification pushed to git.
Because we're on a migration process, our current projects have a lot of branches, and we want to start the build process on some of them.
Issue
Because the Run button of the build starts a build with default branch (AKA master), we can't run a build on a given branch, the need being to have a select box with existing branches that you can select for the build.
Already tried / Invalid solutions
A solution would be to push a dummy commit on each branch to trigger TC and make it see the branch, this way we could select the branch in the run options, but that's not a solution to us because pushing a dummy commit just for that feels wrong.
I can also use the solution provided in Select Git branch for TeamCity Build, but the issue is that we have a lot of branches with quite heavy names, and this solution allows typo, which is not what we want.
Make sure you have correctly configured branch specification in VCS Root settings. In my case:
Go to build configuration, select branch you want to build from and press run:
Working with feature branches from TC docs should be helpful as well.
Hope that helps.
PS: Based on TC 2017.2.1 (build 50732)

TeamCity: dont see Branch Tab in some projects

What the difference in configs ?
Project with Branches Tab:
Project without Branches Tab:
If you only have one branch specified in the VCS config, you won't see a Branches tab.
TeamCity doesn't show branches in a project in case it knows nothing about them, i.e. there are no builds/changes in the project since project have been created. So if there is an old project with builds, newly created one has no knowledge regarding those builds. Try running a build in a branch, it should help.

Get the sources from the branch that triggered the build in Team Services

I would like to create an integration build in VS Team Services, that is triggered when a commit is done to any branch (develop/feature xy) except master.
I am able to create a trigger for this:
but how do i checkout the sources of the branch that triggered the build?
In the task tab, the first step is 'Get Sources' and here i'm only able to choose one branch (the * wildcard is not possible here):
Otherwise for example a build is triggered by a feature branch, but the sources are taken from the develop branch. How can i do this?
You filter is perfectly fine if you want to build anything but master branch.
The branch you select in build definition is just the default branch used when you Queue New Build manually.
OTOH the build trigger establish which branch to download, e.g. if the build has been triggered by a git push on branch develop then that is the one checkout'ed and built.
When you queue a new build manually, you also have the chance to change the default value to whatever branch you would like to build.

Bamboo Branch Updater: Is it possible to build the branch isolated first and then merge with master and build again?

I am having a bit of trouble with the Branch Updater feature of Bamboo.
If a new commit is pushed on a branch that is using the branch updater, Bamboo checks if there are new commits on the dependent branch(in my case the master branch) and if this is the case it merges the changes and runs the build.
However, if this build fails, it is hard to recognize, if the new code on the branch itself is broken or if it just could not be merged correctly with the master. Therefore I would like that in these cases the branch is build independently first and only if this build is successful, the changes on the master are merged in and the branch is build again.
Is this possible using the branch updater feature?
A workaround might be to use multiple build plans and use one to build all branches isolated and another plan to integrate everything using the branch updater.
The "Branch Updater" feature is to merge the code from master branch into feature branch after a successful build of the master branch.
However, currently there is NO straight forward option in Bamboo (except the workaround mentioned in your OP) to build the branch and auto merge only if the branch build is successful.
Typically, the developer runs the build in local and commit the changes to repository if the local build is successful. There are two things that can go wrong.
1) While running the local build, the latest code from feature branch is not available in local. Some of the repos like GIT would complain if the local doesn't match with HEAD revision, you need to update to HEAD before you commit the changes. In this case, you can run the build again to ensure there is no problem.
2) When the master code merges with feature branch, something could go wrong
I understand that still there is a gap which can be addressed to resolve the point 2.
You can create a ticket in Bamboo with detailed explanation of the use case to add this feature.

TeamCity don't trigger automatic build

I'm dumb with continuous integration and noticed a behavior that does not seem right..
I'm using Mercurial with TeamCity. When I push changes the TeamCity detect the changes but don't run the build automatically. This is correct behavior? He should not detect the changes and run the build automatically?
Triggers are not added to build configurations by default in TeamCity. You'll need to go to the settings for the configuration and click on "Build Triggers" then "Add Trigger". The type of trigger I believe you are looking for is a "VCS Trigger".
The documentation for this feature can be found here.
I believe my issues was misunderstanding what was needed in Branch Filters. I thought I was supposed to enter the GIT refs I wanted to have builds triggered from
This wasn't working for me
+:refs/heads/*
-:refs/heads/releases/6.7.3
-:refs/heads/releases/6.8.30
-:refs/heads/releases/6.8.32
-:refs/heads/releases/6.8.34
And this is what finally figured out (I think) is that it is asking for the branch names inside TeamCity itself (the help text says "Newline-delimited set of rules in the form of +|-:logical branch name")
This worked for me, to trigger builds from the branch (GIT ref refs/heads/master for me, look back in your VCS Root setup) and all other branches except those labeled "releases/6.7.3", "releases/6.8.30", "releases/6.8.32" and "releases/6.8.34"
+:*
-:releases/6.7.3
-:releases/6.8.30
-:releases/6.8.32
-:releases/6.8.34

Resources