3

Given TeamCity & our Github repo and a CI flow matching Github Flow.

I want to be able to start my build process by first merging master into a Pull Request's branch.

If that succeeds, then it can go on with the rest of the build steps.

Can this be configured in TeamCity with builtin functionality? Or do I have to create a build step & write a shell script that does this and returns success/fail as my first step?

Mark Evans
  • 810
  • 10
  • 18

1 Answers1

6

This is for the most part supported out of the box in TeamCity if you intend to automatically build all PR branches.

There is a detailed article on this here: http://blog.jetbrains.com/teamcity/2013/02/automatically-building-pull-requests-from-github-with-teamcity/

The key part is that your VCS root branch specification uses the wildcard pattern +:refs/pull/(*/merge)

The "pull" part means all open pull requests qualify as source, the "merge" part means that each pull request is merged with the master branch before running the build config - which is exactly what we want in this case (an alternative is "head" to build the branch in isolation).

We've been running this successfully in our environment. In your scenario you can trigger other build configs (or an automated merge into master) based on the success of the PR test build steps / config.

I recommend installing the plugin mentioned in the article to automatically update the build status in your PRs - helpful.

As a follow-up check out the TeamCity Automatic Merge feature: https://confluence.jetbrains.com/display/TCD9/Automatic+Merge

BrokenGlass
  • 158,293
  • 28
  • 286
  • 335
  • so can I trust that no matter what if master is getting updated that this reference and github will always point to an updated merge of master on the pull request branch? Would my build break ( as desired) if the reference would have merge conflicts? – Mark Evans Aug 19 '15 at 14:32
  • yes - TeamCity should automatically trigger a rebuild of your open PR branches whenever master gets updated - this rebuild will be your PR changes being merged into master. Merge conflicts would also be indicated - I'd suggest setting up the build status update plugin for getting all of this feedback automatically. – BrokenGlass Aug 19 '15 at 18:34
  • Do you know if it's possible to do this with bitbucket instead of github? – Frederik Baetens Aug 12 '22 at 16:32