Created
April 7, 2019 18:45
-
-
Save Branyac/7b5a29f710ad239892d3a29c8cbc31d0 to your computer and use it in GitHub Desktop.
AzureDevOps-CloneTestPlan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script explained at https://thingsandcode.com/2019/04/19/clone-azure-devops-test-plans-with-powershell/