4

I've been trying to configure our TC installation to work with the following scenario:

We have multiple developers working on multiple bugs in parallel. Our source code is stored in github and we are using pull requests. I'd like Teamcity to trigger a build on pull request as described here: http://blog.jetbrains.com/teamcity/2013/02/automatically-building-pull-requests-from-github-with-teamcity/ which seems quite easy to do. Unfortunately it looks like such configuration doesn't MERGE the pull request, but simply PULL it from the repository.

Let me give you an example:

Developer A opens pull request nr 1 (based on code version 0010). Developer B opens a pull request nr 2 also based on code version 0010. Current code version in the repository is 0015. Our TeamCity server for each pull request should first checkout the version 0015 of the source code, then merge changes in pull nr 1. If this merge is successful, then it should try and compile the code. Similar should be done for pull nr 2.

Mind you that I need TC to merge against the CURRENT version of the code in the branch, not just pull the version from the pull request.

Pull request nr 1 is reviewed and accepted, and merged into the production repository. This should trigger a rebuild of pull request nr 2, as now the current branch is not 0015, but 0015 with the code from pull nr 1.

I understand that with many pull requests, every merge triggers an avalanche of builds/rebuilds. But this is exactly what I need TC for. Part of the Continuous Integration process should be making sure that the source code from a pull request should merge with the current head without any conflicts.

After configuring the TC server as described in the link, it doesn't really merge against the HEAD, but simply performs git pull and compile. Which is not helpful at all, as this should always work (provided that the developer is compiling the code on their machine before they commit changes).

I'd appreciate any hints or ideas on how to set our CI environment co we can test an actual merge against the most current code, not just a simple compilation.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
Michal Rogozinski
  • 1,713
  • 1
  • 17
  • 23

3 Answers3

2

TeamCity can do this. Directions are in the link you pointed to: (https://blog.jetbrains.com/teamcity/2013/02/automatically-building-pull-requests-from-github-with-teamcity/)

In short, use +:refs/pull/*/merge as the branch specification to have TeamCity use the merged PR branch. Using +:refs/pull/*/head just builds the unmerged branch as you are describing.

AndyL
  • 341
  • 1
  • 2
  • 8
0

I don't believe teamcity can do that out of the box. You might be able to achieve it with making your own plugin but you're probably better off using a webhook.

Take a look at http://blogs.atlassian.com/2013/05/git-automatic-merges-with-server-side-hooks-for-the-win/ it describes something similar and has a script that you can repurpose to you needs.

JonSquared
  • 683
  • 6
  • 19
0

TeamCity 8.1 introduced Automatic Merge functionality to merge a branch into another after a successful build.

https://confluence.jetbrains.com/display/TCD9/Automatic+Merge

dragon788
  • 3,583
  • 1
  • 40
  • 49