Reputation: 1120
I'm moving a particular set of builds from an existing Visual Studio Team Service project to a new one. Unfortunately, I cannot locate a way to migrate the build definitions from one project to another. There doesn't appear to be an import/export function or another mechanism.
Is there a way to move these without manually recreating the builds in the new project?
Upvotes: 19
Views: 8392
Reputation: 11
In
On the Source project export (via ...) each build definition
On the Destination project, in the folder view for build definitions, New->Import one and adjust: Agent Pool Repository Path (to be reviewed later, while saving the import)
Export the successfully imported build definition
Upvotes: 0
Reputation: 186
You could do something like the following:
$project1Url = "http://tfs:8080/tfs/collection/project1/_apis/build/definitions/$($buildId)?api-version=2.0"
$obj = Invoke-RestMethod -Uri $project1Url -Method Get -ContentType "application/json" -UseDefaultCredentials
$obj.project = $null
#TODO: Update all repository/source control info, too.
$json = ConvertTo-Json $obj -Depth 3
$project2Url = "http://tfs:8080/tfs/collection/project2/_apis/build/definitions/?api-version=2.0"
Invoke-RestMethod -Uri $url -Method Post -Body $json -ContentType "application/json" -UseDefaultCredentials
The gist is: Get the existing definition from the source project (projec1), clear the project ties, set the new repository information as needed, and send the new definition as a POST (CREATE) to the target project (project2).
Upvotes: 4
Reputation: 305
You can use the REST APIs to perform this. There is an example shown here.
It shows how to get the JSON response of a build definition and again using the same reference to make a new one in the project you desire.
Upvotes: 2
Reputation: 51093
There's no way to copy or sync a vnext build definition template between team projects. The build definition template is only for the present team project. So you need to create a build definition template for each team project.
And also there have been a feature request on UserVoice, you can vote up and monitor it
VSO build vnext: share build templates between projects https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/8468566-vso-build-vnext-share-build-templates-between-pro
However, it can be achieved using the API. Here is a simple tool you can use. (Need to be in the same team project collection.)
Upvotes: 3
Reputation: 211
This is now available from within the VSTS Build Definitions web UI:
.
Upvotes: 17
Reputation: 29966
There is an Export/Import Build Definition extension in Visual Studio Marketplace you can use now.
Upvotes: 13