如何覆盖 <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 公开为 <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:PackagesMyProject\%teamcity.build.branch%
它以 E:PackagesMyProject<default>
结束 - 然后由于它不是有效的 Windows 路径而导致构建步骤崩溃.
it's ending up with E:PackagesMyProject<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:TeamCityBuildAgentsagent-mulderwork2151838a7933464d
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.
在我的情况下,我有
%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屋!