我正在尝试自动化一些与构建相关的任务,包括为每个版本创建新的发布分支和构建定义。我使用VSTS TFVC进行版本管理。当我尝试使用TFS时,我找不到任何用于创建分支(microsoft文档)的API。
我可以看到.NET API可以这样做;无法找到一个作为REST。
发布于 2018-08-03 07:38:33
目前还没有这样一个REST来创建分支,我已经提交了一个这里的用户声音来建议这个特性,你可以去投票让它在将来达到这个目的。
作为一种解决方法,您可以尝试以下方法来创建代码或脚本中的分支:
CreateBranch()
类中使用“Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer”方法来创建分支。tf branch olditem newitem [/version:versionspec] [/noget] [/lock:(none|checkin|checkout)] [/noprompt] [/silent] [/checkin] [/comment:("comment"|@commentfile)] [/author:authorname] [/login:username, [password]] [/recursive]
发布于 2018-08-02 08:08:07
正如您在“分支”页面中看到的那样,没有任何方法可以使用Rest创建分支。而且大多数情况下,您现在只能使用版本控制API读取/获取信息。
如果您不想使用C#,您可以使用Powerhshell实现流程自动化:
param(
)
begin
{
# load the required dll's
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
}
process
{
$server = New-Object Microsoft.TeamFoundation.Client.TeamFoundationServer("http://tfsserver:8080/tfs/DefaultCollection")
$vcServer = $server.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]);
$changesetId = $vcServer.CreateBranch('$/Demo/Code/Main', '$/Demo/Code/Dev/Branch', [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest, $null, "New branch from script", $null, $null, $null)
"Branch created with ChangesetID: $changesetId"
}
https://stackoverflow.com/questions/51648448
复制相似问题