在 TFS 2015 自动构建中使用分支名称 [英] Use Branch Name in TFS 2015 Automated Build

查看:34
本文介绍了在 TFS 2015 自动构建中使用分支名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 TFS 存储库具有以下结构:

My TFS repo has the following structure:

Project
 - Dev
    - 1.0.0_Branch1
    - 1.1.0_Branch2
    - N.0.0_BranchN

分支是 TFS 中的实际分支.

The branches are actual branches in TFS.

我在 TFS 服务器上为此项目设置了自动 CI 构建.我遇到的问题是我需要 TFS 中的构建名称才能使用分支的名称.

I have an automated CI build set up for this project on a TFS server. The issue I am having is that I need the build name in TFS to use the name of the branch.

我尝试了此处列出的许多构建定义变量,例如 $(SourceBranchName) 和 $(Build.SourceBranchName) 但所有这些都使用项目名称(本示例中的项目).

I have tried a number of the build definition variables listed here , for examle $(SourceBranchName) and and $(Build.SourceBranchName) but all of these are instead using the name of the Project (Project in this example).

我希望构建按照 1.0.0_Branch1.1 的行命名,最后一个数字是修订版.

I would like the build to be named along the lines of 1.0.0_Branch1.1 with the last number being the revision.

我想这样做的原因是当我在构建结束时生成 Nuget 包时,可以使用正在构建的分支的版本对它们进行版本控制.目前,它们正在使用日期进行版本控制,这意味着最高版本只是最近构建的版本,实际上可能并非如此.我不想每次都手动设置版本.

The reason I would like to do this is so that when I generate Nuget packages at the end of the build, they can be versioned using the version of the branch that is being built. Currently they are being versioned using the date which means that the highest version is only ever the most recently built, which may not be the case in practice. I don't want to have to manually set the versions each time.

正在构建的所有程序集都正确版本化以匹配它们所在的分支.

All assemblies that are being built are correctly versioned to match the branch that they are within.

有没有办法做到这一点?

Is there a way to achieve this?

推荐答案

这可能是由您在构建定义的存储库"选项卡下配置的映射"设置引起的.当您使用 TFVC 存储库构建时,BUILD_SOURCEBRANCHNAME 变量将填充工作区根服务器路径中的最后一个路径段.所以我想知道您的构建定义中映射的服务器路径是$/Project"而不是$/Project/Dev/1.0.0_Branch1".

This could be caused by the "Mappings" setting you configured under "Repository" tab in your build definition. When you build with TFVC repository, the BUILD_SOURCEBRANCHNAME variable is filled with the last path segment in the root server path of the workspace. So I'm wondering that the mapped server path in your build definition is "$/Project" rather than "$/Project/Dev/1.0.0_Branch1".

TFVC repo 分支:根服务器路径中的最后一个路径段工作区.例如在 $/teamproject/main 这个值是 main.

TFVC repo branch: The last path segment in the root server path for the workspace. For example in $/teamproject/main this value is main.

详情请参考此链接:预定义变量.

这篇关于在 TFS 2015 自动构建中使用分支名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆