TFS 2017是否可以将构建定义导出和导入到远程服务器? [英] Does TFS 2017 have the ability to export and import build definitions into remote server?

查看:102
本文介绍了TFS 2017是否可以将构建定义导出和导入到远程服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在内部服务器上安装了Team Foundation Server 2017,该服务器在沙盒环境中构建.NET代码,但希望能够(向客户端-生产服务器)远程推出新的构建定义或更新。

解决方案

是的,您可以在TFS 2017中导出和导入构建定义。



在这种情况下,如果您有权从远程服务器访问和创建构建定义,则可以直接导出/导入构建定义。参考下面的截图。



此外,您还可以使用扩展名


We have Team Foundation Server 2017 setup on our internal server which we build our .NET code in our sandbox environment, but would like to be able to push out new build definitions or updates remotely (to our client - production server) either manually or in an automated manner?

解决方案

Yes, you can export and import the build definitions in TFS 2017.

In you case, if you have the permission to access and create build definitions from the remote server, then you can export/import the build defintions directly. Reference below screenshot.

Besides, you can also use the extension Export/Import Build Definition.

To update the build definition, you can use the REST API (Update a build definition) with the PUT method:

e.g.:

PUT http://server:8080/tfs/DefaultCollection/Project/_apis/build/definitions/29?api-version=2.0

Content-Type: application/json
{json body here}


UPDATE:

You can reference below sample to update the build definiton:

Param( 

   [string]$baseurl = "http://server:8080/tfs/Collection",   

   [string]$projectName = "ProjectName",

   [string]$builddefinitionID = "29",

   [string]$keepForever = "true", 

   [string]$user = "username", 

   [string]$token = "password" 

) 

# Base64-encodes the Personal Access Token (PAT) appropriately 

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token))) 


function CreateJsonBody 

{ 

    $value = @" 

{ 

  body here

}  


"@ 



 return $value 

} 


$json = CreateJsonBody 


$uri = "$baseurl/$($projectName)/_apis/build/definitions/$($builddefinitionID)?api-version=2.0" 

$result = Invoke-RestMethod -Uri $uri -Method Put -Body $json -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} 

这篇关于TFS 2017是否可以将构建定义导出和导入到远程服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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