简体   繁体   English

TeamCity 根据拉取请求构建特定分支

[英]TeamCity building specific branch on pull request

I have a solution that consists of several projets like this:我有一个由几个这样的项目组成的解决方案:

MySolution
-Project1
-Project2
-Project3

For each project I have a branch on github, for example Project1Branch, Project2Branch... I have configured triggers on teamcity for builing containers on pullrequest into master.对于每个项目,我在 github 上都有一个分支,例如 Project1Branch、Project2Branch ...... But when it happens all three projects are build, though changes are made only in Projeсt1.但是当它发生时,所有三个项目都已构建,尽管仅在 Projeсt1 中进行了更改。 I tried to configure branch filter in triggers for build step +:Project1* but in doesn't work.我尝试在触发器中为构建步骤+:Project1*配置分支过滤器,但不起作用。 How can i solve this issue?我该如何解决这个问题?

TL;DR TL;博士

  • Leave your Trigger branch filters to +:* .触发器分支过滤器保留为+:*
  • In the Pull Requests build feature, configure the "source" to Project1Branch and "target" to master branches.拉取请求构建功能中,将“源”配置为Project1Branch ,将“目标”配置master分支。
  • Keep your VCS configuration minimal (see below).保持您的VCS配置最少(见下文)。

For Project1 to build at each MR of Project1Branch into master :Project1BranchProject1的每个 MR 处构建到master

Only watch the Project1Branch branch. Project1Branch分支。 In your VCS configuration :在您的VCS 配置中:

  • Default branch: refs/heads/Project1Branch默认分支: refs/heads/Project1Branch
  • (optional unless you need branch-filtered build steps) Branch specification: Project1Branch (可选,除非您需要分支过滤的构建步骤)分支规范: Project1Branch

Add the merge-request/... branches that match your pattern to the watched branches.将与您的模式匹配的merge-request/...分支添加到被监视的分支。 Pull Request Filtering :拉取请求过滤

  • By source branch: +:refs/heads/Project1Branch按源分支: +:refs/heads/Project1Branch
  • By target branch: +:refs/heads/master按目标分支: +:refs/heads/master

Trigger on every change in watched branch.触发监视分支中的每个更改。 Triggers :触发器

  • Branch filters: +:*分支过滤器: +:*

If you only want to trigger on MR branches, do Triggers :如果您只想在 MR 分支上触发,请执行Triggers

  • Branch filters:分支过滤器:
+:*
-:Project1Branch

The same goes for Project2 and Project3 . Project2Project3也是如此。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM