为此我所做的是创建多个 VCS 配置和 3 个独立的项目。
- 基础仓库:默认分支:master
- Base Repo:默认分支:master + 分支规范
+:/refs/pull/*/merge
- UI Repo:默认分支:master
- UI Repo:默认分支:master + 分支规范
+:/refs/pull/*/merge
- 插件仓库:默认分支:master
- 插件仓库:默认分支:master + 分支规范
+:/refs/pull/*/merge
基础回购拉取请求:
我们将构建 Base Repo 的 Pull Request (2)
这个项目将使用master 版本的 UI Repo 构建拉取请求。 (3)
此项目将使用 master 版本的插件仓库构建拉取请求。 (5)
UI 回购拉取请求:
我们将构建 UI Repo (4) 的拉取请求
该项目将使用master 版本的基础回购构建拉取请求。 (1)
该项目将使用master 版本的插件仓库构建拉取请求。 (5)
插件拉取请求:
我们将构建插件仓库的拉取请求(6)
这个项目将使用master 版本的基础仓库构建拉取请求。 (1)
此项目将使用master 版本上的 UI 测试构建拉取请求。 (3)
编辑:
如何处理拉取请求
从评论中,我完成了这个答案。
我创建了一个watcher,以便自动启动拉取请求的构建。 watcher 是一个 TeamCity 构建,它使用 schedule trigger 功能定期运行。
这是该功能的伪代码
parameters:
- ValidatorName
Load Octokit
// Filter is on every Open Pull Request
openPR = Octokit.PullRequest.GetAllForRepository(filter);
foreach(pr in openPR) {
// Define if the PR should be queued.
// Check if the PR is not already queued.
queuedBuilds = Execute-HttpGetCommand ("http://<teamcityServerUrl>/httpAuth/app/rest/buildQueue?locator=buildType:validatorName");
foreach(queued in queuedBuilds) {
if(queued.branchName = pr.Number) {
# Flag to not queue the build.
shouldQueue = false;
}
}
if(shouldQueue) {
Execute-HttpPostCommand(
"http://<teamcityServerUrl>/httpAuth/app/rest/buildQueue",
"<build branchName=""pr.Number""><buildType id=""validatorName""/><comment><text>Automatic launcher of Pull Request</text></comment></build>");
}
}
validator 的概念出现了,它是一个特殊的构建,具有我们想要在拉取请求上测试的快照依赖项。
此构建将加载 octokit 并使用 Octokit.MergePullRequest 对象。