简体   繁体   English

如何使TeamCity自动将Git功能分支与master合并,并在合并冲突的情况下使构建失败?

[英]How do I get TeamCity to automatically merge a Git feature branch with master and fail the build in case of merge conflicts?

Our development/release cycle works like this: 我们的开发/发布周期如下所示:

  1. Developer creates a feature branch, implements a feature 开发人员创建功能分支,实现功能
  2. Developer indicates feature is ready for acceptance testing (UAT) 开发人员指示功能已准备好进行验收测试(UAT)
  3. Tester deploys feature branch and accepts (or rejects) feature 测试人员部署功能分支并接受(或拒绝)功能

Accepted features are then merged into the master branch by the tester , and will therefore be released during the next release cycle (we deploy the trunk/master code weekly). 然后,测试人员将接受的功能合并到master分支中,因此将在下一个发布周期中发布(我们每周部署中继/主代码)。

We're having frustrations with merge conflicts, because by the time the tester has UAT'ed the feature and discovered that it won't merge cleanly, the developer who worked in it has normally moved on to something else. 我们对合并冲突感到沮丧,因为当测试人员对UAT进行功能化并发现它不会干净地合并时,从事该功能的开发人员通常会转移到其他方面。

We're considering a solution whereby every feature branch is automatically merged, by TeamCity, against the current master branch, and any build resulting in a merge conflict is considered a failed build - this will give us early visibility on problematic merges so we can fix them sooner. 我们正在考虑一个解决方案,其中TeamCity会自动将每个功能分支与当前的主分支合并,并且任何导致合并冲突的构建都将视为失败的构建-这将使我们能够早日了解有问题的合并,以便我们进行修复他们更快。

TeamCity doesn't appear to have built-in support for this workflow (ie when a push happens to branch X, checkout master, merge branch X onto it, build, unit-test, create package). TeamCity似乎没有对此工作流的内置支持(即,当对分支X进行推送,签出母版,将分支X合并到其上,构建,单元测试,创建程序包时)。 Has anyone created a similar workflow using TeamCity and Github - using custom msbuild targets, perhaps? 是否有人使用TeamCity和Github创建了类似的工作流程-也许使用自定义msbuild目标?

EDIT: I should clarify that we're using Github but we're not currently using pull requests - sounds like this is something I should investigate. 编辑:我应该澄清一下,我们正在使用Github,但我们当前未在使用请求请求-听起来这是我应该调查的事情。 :) :)

If you're using Github and Pull Requests then check out Hadi Hariri's blog post about how to get the pull request after it has been merged with master: 如果您使用的是Github和Pull Requests,请查看Hadi Hariri的博客文章,了解如何在与master合并后如何获取Pull Request:

http://hadihariri.com/2013/02/06/automatically-building-pull-requests-from-github-with-teamcity/ http://hadihariri.com/2013/02/06/automatically-building-pull-requests-from-github-with-teamcity/

Github does an automatic merge for every pull request and the resulting merge is available (though pretty much undocumented) as Github会为每个拉取请求进行自动合并,并且可以使用生成的合并(尽管几乎未记录)为

git fetch origin +refs/pull/298/merge

where pull request id is 298. And so all merged pull requests can be fetched with a wildcard in place of the id in Teamcity and be built automatically. 其中请求请求ID为298。因此,可以使用通配符代替Teamcity中的ID来获取所有合并的请求请求,并自动进行构建。 The branch specification would look like this: 分支规范如下所示:

+refs/pull/*/merge

EDIT: You say you're not using pull requests so I guess you could do this with some git commands. 编辑:您说您没有使用请求请求,所以我想您可以使用一些git命令来做到这一点。 I haven't tried this out myself so these are only a few tips to get you started. 我自己还没有尝试过,所以这些只是帮助您入门的一些提示。

  1. Use the branch specification feature in Teamcity to get the branch. 使用Teamcity中的分支规范功能来获取分支。 Set the checkout mode to check out the code on the agent 设置检出模式以检出代理上的代码
  2. In a build step merge the master branch into the target branch. 在构建步骤中,将master分支合并到目标分支。 If master is not available on the agent you might have to fetch it first. 如果master在代理上不可用,则可能必须先获取它。 If you get any errors, then the build fails. 如果出现任何错误,则构建将失败。

To check for merge conflicts, one of these strategies should work. 要检查合并冲突,应使用以下策略之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何git合并已经解决与master冲突的分支? - How do I git merge a branch that has already resolved conflicts with master? 使用git扩展如何在不更改功能分支的情况下将我的功能分支合并到主分支中? - Using git extension how do I merge my feature branch into the master branch without changing my feature branch? Git:解决合并冲突后如何返回分支? - Git: How do I return to the branch after fixing merge conflicts? 修复git merge分支到master的冲突 - fix conflicts for git merge branch to master Git将发布分支合并到主要冲突中 - Git merge release branch into master conflicts 在每次构建之前,如何让TeamCity将Master合并为Pull Request? - How do I get TeamCity to Merge master into Pull Request before each build? 如何从Git中的功能分支将上游/母版合并到原始/母版中? - How to merge upstream/master into origin/master from a feature branch in Git? 如何在git中有选择地将文件从分支合并到master? - How do I selectively merge files from branch into master in git? 如何安全地将 Git 分支合并到 master 中? - How do I safely merge a Git branch into master? 我如何将此功能/react-intl 分支与 Git 合并? - How do I Merge this feature/react-intl branch with Git?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM