为 TeamCity Build 选择 Git 分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23415704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Select Git branch for TeamCity Build
提问by Joe
I'm wondering how to select the branch to build against using Team City 8.1.
我想知道如何选择使用 Team City 8.1 构建的分支。
My VCS root (Git) is set to Default: "master" and Branch specifications are
我的 VCS 根 (Git) 设置为默认值:“master”和分支规范是
+:refs/heads/develop
+:refs/heads/feature/*
+:refs/heads/hotfix/*
+:refs/heads/master
+:refs/heads/release/*
I have a CI build set up that automatically builds anything that is checked in, which is working exactly how I want.
我有一个 CI 构建设置,可以自动构建任何签入的东西,这正是我想要的。
What I'd like to do is create a scheduled QA build/deployment against the "develop" branch. I see that if I click the ellipsis next to the run button, I can choose the branch on the "Changes" tab, but I'm unable to determine how to make this "stick". Is this possible, or am I going about this wrong?
我想做的是针对“开发”分支创建预定的 QA 构建/部署。我看到如果我点击运行按钮旁边的省略号,我可以选择“更改”选项卡上的分支,但我无法确定如何使这个“坚持”。这是可能的,还是我做错了?
Thanks,
谢谢,
Joe
乔
回答by Joe
Based on @biswajit-86 's feedback and some other information I found while googling this, I was able to get this to work. Here's what I did (image-heavy, sorry). It's based on Team City 8.2 which seems to be set up a little differently than the examples I came across.
根据@biswajit-86 的反馈和我在谷歌搜索时发现的其他一些信息,我能够让它发挥作用。这就是我所做的(图像繁重,抱歉)。它基于 Team City 8.2,它的设置似乎与我遇到的示例略有不同。
1) Set up a VCS root. Key here is the %BranchName%
parameter.
1) 设置一个 VCS 根。这里的关键是%BranchName%
参数。
2) Create a Build template and use the VCS root that was just created. I also added an MSBuild step as all of my builds need to run this.
2) 创建一个 Build 模板并使用刚刚创建的 VCS 根。我还添加了一个 MSBuild 步骤,因为我的所有构建都需要运行它。
3) Create a new build, based on the template. As you can see here, the %BrachName%
parameter that was created in step 1 is available.
3) 基于模板创建一个新版本。正如您在此处看到的,%BrachName%
在步骤 1 中创建的参数可用。
4) If you need to change this later, it's available here
4) 如果您以后需要更改此设置,可在此处获得
And that's pretty much it. For my CI build, I left the branch name empty so any branch that is checked in triggers the MSBuild step. For my QA build, I pass in "develop" as shown here and I have this set up on a daily schedule. I also have a "release" build set up, but based on our naming conventions it looks like I need to update the build to point to the specific branch per release.
仅此而已。对于我的 CI 构建,我将分支名称留空,因此任何签入的分支都会触发 MSBuild 步骤。对于我的 QA 构建,我传递了“开发”,如下所示,并且我每天都设置了这个。我也有一个“发布”构建设置,但根据我们的命名约定,看起来我需要更新构建以指向每个发布的特定分支。
回答by Biswajit_86
You can parameterize the "Ref name" of the git VCS setup. What this means is you declare a variable of the form %variable.name%
in your build, create a build parameter under the "configuration parameter:" category.
您可以参数化 git VCS 设置的“Ref name”。这意味着您%variable.name%
在构建中声明了一个形式的变量,在“配置参数:”类别下创建一个构建参数。
For each build target set this value and you should be able to pick the specific branch that you want to run the target for.
为每个构建目标设置此值,您应该能够选择要为其运行目标的特定分支。