如何覆写< default>分支名称在TeamCity 7.1使用Git分支支持? [英] How can I override the <default> branch name in TeamCity 7.1 using Git branching support?
问题描述
我有一个CI构建从Github中提取功能分支,并使用基于项目,分支和内部版本号的文件夹命名约定将它们构建/打包到本地文件夹中。
I've got a CI build pulling feature branches from Github and building/packaging them into a local folder, using a folder naming convention based on the project, branch and build number.
对于命名的分支(feature1,feature2),这是非常好的。
For named branches (feature1, feature2) this is working great.
问题是当我做一个提交给master,TeamCity暴露teamcity。 build.branch as < default>
- 这意味着构建步骤扩展时
The problem is that when I do a commit to the master, TeamCity exposes teamcity.build.branch as <default>
- which means when the build step expands
E:\Packages\MyProject\%teamcity.build.branch%\
结尾是 E:\Packages\MyProject\< default>
- 这将导致生成步骤崩溃,因为它不是有效的Windows路径。
it's ending up with E:\Packages\MyProject\<default>
- which is then crashing the build step because it isn't a valid Windows path.
我可以在完全限定构建参数中查看主分支名称:
I can see the master branch name in the fully-qualified build parameter:
teamcity.build.branch <default>
teamcity.build.checkoutDir C:\TeamCity\BuildAgents\agent-mulder\work\2151838a7933464d
teamcity.build.default.checkoutDir 2151838a7933464d
teamcity.build.id 16347
teamcity.build.vcs.branch.github_myproject refs/heads/master
需要获取 master 作为teamcity.build.branch以在我的构建步骤中使用。
but ideally I need to get master as the teamcity.build.branch for use in my build steps.
我可以在运行时转换参数吗?覆盖行为?我甚至尝试将VCS分支名称设置为DO_NOT_USE,希望master不再匹配默认值 - 但这似乎也不工作。
Can I transform the parameter at runtime? Override the behaviour? I've even tried setting the VCS branch name to DO_NOT_USE in the hope that "master" would no longer match the default - but this doesn't appear to work either.
推荐答案
在teamcity 7它简单的%vcsroot.branch%
返回开发。
In teamcity 7 its simply %vcsroot.branch% that returns develop.
/ p>
In my case I have
%MajorVersion%.%MinorVersion%.%PatchVersion%-%vcsroot.branch%
这些都是在编译参数中设置的。
数字格式是%BuildFormatSemVer%,这是上面的东西。 {0}
Which are all set in build parameters. The number format is %BuildFormatSemVer% which is the stuff above and . {0}
%BuildFormatSemVer%.{0}
这会传回
#1.0.0-develop.4
这篇关于如何覆写< default>分支名称在TeamCity 7.1使用Git分支支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!