Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Apr 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.