Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building merge requests in CI server

We are using GitLab to manage our repos. We are trying to follow GitFlow processes and as part of that we would like to be able to build and execute the tests against any merge request automatically in TeamCity.

From what I can see this is possible in GitLab CI but moving over to that isn't a realistic option for us.

I have seen tutorials about achieving this on GitHUB using a branch specification like +refs/pull/*/merge - does a similar branch specification get created by GitLAB?

We are using version 4.2 of GitLab but can upgrade if required for this feature and version 8 of TeamCity

like image 523
Dave Kirk Avatar asked Oct 01 '13 09:10

Dave Kirk


1 Answers

I have GitLab 6.3 and TeamCity 8 and I need build feature branches too. We have following workflow (it is based on git-flow, but slightly changed according to our release cycle).

So, we have development branch and one pushes feature branch with a specific name dev/feature-name-here.

Next, one creating a Merge Request in GitLab from dev/feature-name-here to development.

TeamCity is configured to automatically run builds for each branch with the following refspec: +:refs/heads/dev/(*) so we can see a build for branch feature-name-here is automatically started.

Next, I have a custom script which is embedded to GitLab's merge request page. It do the following.

  1. Detects a source and target branch by looking at a MR page
  2. With TeamCity REST API enumerates build which is belongs to a target branch (in TeamCity 8 we can assign custom build configuration ID to build so we using some semantic naming like devUnit, devIntegration, devWhatever, etc...)
  3. Creates a table witch contains build status images for source and target branches for each related build configuration.

Now it looks like this:

TC Build status at GitLab

Now this approach has some drawbacks like if one updates a branch with another push I can't figure out from GitLab page is new commits is already built or I'm seeng old build status, so I need to click on a build link and check in TeamCity

like image 116
Olegas Avatar answered Oct 14 '22 04:10

Olegas