Does TFS 2017 have the ability to export and import build definitions into remote server?

纵然是瞬间 提交于 2019-12-11 10:35:09

问题


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?


回答1:


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)} 



来源:https://stackoverflow.com/questions/48778485/does-tfs-2017-have-the-ability-to-export-and-import-build-definitions-into-remot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!