Clone Azure DevOps test plans with Powershell

Tags:  Powershell,  Azure

Imagine the situation: You have a test plan in Azure DevOps that is executed every time you create a new version of your product, but Azure DevOps doesn’t provide an easy way to clone test plans and cloning manually is painful.

Fortunately the Azure DevOps REST API has a Clone Operation for test plans: Clone Operation – Clone Test Plan

I wrote a powershell script to make an API call to Clone operation in an easy way, just follow these steps:

  1. Download the script for cloning Azure DevOps Test Plans.
  2. Change these variables values:
    Image of Powershell script with the values for the variables used in this example

    • $organization: Name of the Azure organization of your project. Marked with a green box.
    • $PAT: Your Azure Personal Access Token (PAT). You must set “Test Management permission” to “Read & write”. For more details about PAT follow instructions at Authenticate access with personal access tokens.
    • $project: Project name that contains the test plan. Marked in yellow.
    • $testPlanId: Id of the test plan you want to clone. Marked in red.
    • $testSuiteId: Id of the test suite you want to clone. Marked in purple.

    Image of Powershell script with the parameters marked with colours

Open powershell and execute script, if succeded it will return OK.
After the execution of the Powershell script it returns ok

Clone operation is asyncronous, if the new test plan is empty just wait a few seconds and reload page.
Result of the Powershell script execution


Sergio Monedero

I am excited to share my knowledge and insights on programming and devops through this personal website. I am a lifelong learner with a passion for technology, and I enjoy staying up-to-date on the latest industry trends.

Keep in touch with Me: SergioCoder@LinkedIn | Branyac@Github