Skip to content

Instantly share code, notes, and snippets.

@Branyac
Created April 7, 2019 18:45
Show Gist options
  • Save Branyac/7b5a29f710ad239892d3a29c8cbc31d0 to your computer and use it in GitHub Desktop.
Save Branyac/7b5a29f710ad239892d3a29c8cbc31d0 to your computer and use it in GitHub Desktop.
AzureDevOps-CloneTestPlan
$organization = "your_organization_name"
$PAT = "your_PAT"
$project = "your_project_name"
$planId = "testplan_id_from"
$suiteId = "testsuite_id_from"
$cloneTo = "name_of_new_testplan"
$authorization = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$PAT"))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept-Charset", 'UTF-8')
$headers.Add('Content-Type','Application/Json')
$headers.Add('Authorization',"Basic $authorization")
$postParams=@"
{
"destinationTestPlan": {
"name": "$cloneTo",
"Project": {
"Name": "$project"
}
},
"options": {
"copyAncestorHierarchy": true,
"copyAllSuites": true
},
"suiteIds": [
$suiteId
]
}
"@
$apiUrl = "https://dev.azure.com/$organization/$project/_apis/test/Plans/$planId/cloneoperation?api-version=5.0-preview.2"
Invoke-WebRequest -Uri $apiUrl -Method POST -Headers $headers -Body $postParams | Select-Object -Expand StatusDescription
@Branyac
Copy link
Author

Branyac commented Apr 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment