How would I configure TeamCity to support a GitHub pull-request model for source-code integrations?
Asked Answered
P

2

12

We use TeamCity and GitHub Enterprise. We use an open-source-esque workflow with git: there's a mainline repository for each component, and when people want to make changes, they

  • fork mainline to their own account (so there might be many forks)
  • create a branch in their fork
  • implement change
  • bring up to date with mainline/master for changes that have happened in the meantime
  • submit a pull request of fork/feature-branch -> mainline/master

We're very happy with this workflow; it forces a code-review (well, at least a manual step, which hopefully involves actually reading the code and running its tests) before mainline sees any changes, which historically has been a problem. We'd like to use the GH Status API (blog post, API doc) to turn the merge button non-green if the author is the person looking at the pull-request, but that's for later.

We have TeamCity 7.1 set up to watch the mainline repositories and build when changes are seen. However, the way it's currently set up, CI only builds when it sees changes to mainline/master.

How should we configure our VCS roots in TeamCity such that we can have the same workflow, but CI will trigger a build based on branches in forks of the mainline repo? Preferably without our having to register every fork individually?

I've read TeamCity 7.1's feature-branch documentation (blog post, release notes, documentation), but I don't see how to apply it to our model of arbitrary-number-of-forks as opposed to everyone-commits-to-mainline-in-feature-branches.

Pleat answered 19/9, 2012 at 12:32 Comment(0)
D
7

You can monitor pull-requests by teamcity: http://blog.jetbrains.com/teamcity/2013/02/automatically-building-pull-requests-from-github-with-teamcity/

Difficult answered 6/3, 2014 at 10:58 Comment(1)
Just remember that the user account you configure TC to use must have write access if you tell it to notify Github of the status.Edentate
A
4

To my knowledge TeamCity will not "seek out" your github forks in any automated fashion.

I would solve this by creating a vcs root for each developer's forked repo, and the mainline repo. Then attach each of those roots to the build. Docs.

Unfortunately it is a manual process. Once per developer, per component repo. If I really wanted to automate this I'd look at a combination of Github Hooks and adding vcs roots via the TeamCity REST Api.

Applewhite answered 2/12, 2012 at 17:5 Comment(1)
Or not. All github pull requests are special branches that you can add to your build config: +:refs/pull/*/head. Done.Edentate

© 2022 - 2024 — McMap. All rights reserved.