Share via


Clone operation

TFS 2017 | TFS 2015 | TFS 2013

Note

Looking for REST APIS that support TFS 2018 or later versions? See the Azure DevOps REST API Reference.

api-version = 3.0-preview

If you haven't already, look at the information on getting started with these APIs.

Clone test suite

POST https://{instance}/DefaultCollection/{project}/_apis/test/plans/{planId}/suites/{suiteId}/cloneOperation?api-version={version}
Content-Type: application/json
{
  "destinationSuiteId" : "int",
  "destinationSuiteProjectName" : "string",
  "options" : "CloneOptions"
}
Parameter Type Default Notes
URL
instance string TFS server name ({server:port}).
project string Name or ID of the project.
planId int ID of the test plan in which suite to be cloned is present
suiteId int ID of the test suite to be cloned
api-version string Version of the API to use.
Body
destinationSuiteId int Contains ID of the suite to be cloned.
cloneOptions CloneOptions Options for cloning can be passed. Clone options include : relatedLinkComment, copyAllSuites, copyAncestorHierarchy, destinationWorkItemType, cloneRequirements, overrideParameters.
destinationSuiteProjectName string Destination project name

Sample request

POST https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1/Suites/2/cloneOperation?api-version=3.0-preview.1
{
  "destinationSuiteId": 13,
  "destinationSuiteProjectName": "fabrikam-fiber-tfvc2",
  "cloneOptions": {
    "copyAncestorHierarchy": true,
    "overrideParameters": {
      "System.AreaPath": "fabrikam-fiber-tfvc2",
      "System.IterationPath": "fabrikam-fiber-tfvc2"
    }
  }
}

Sample response

{
  "opId": 3,
  "creationDate": "0001-01-01T00:00:00",
  "completionDate": "0001-01-01T00:00:00",
  "state": "queued",
  "message": null,
  "cloneStatistics": null,
  "resultObjectType": "testSuite",
  "destinationObject": {
    "id": "14",
    "name": "simpleCloned",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc2/_apis/test/Plans/13/Suites/14"
  },
  "sourceObject": {
    "id": "1",
    "name": "TestSuite1",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1/Suites/2"
  },
  "destinationPlan": {
    "id": "18",
    "name": "DestinationPlan",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc2/_apis/test/Plans/18"
  },
  "sourcePlan": {
    "id": "1",
    "name": "TestPlan1",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1"
  },
  "destinationProject": {
    "name": "fabrikam-fiber-tfvc2",
    "url": "https://mytfsserver/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc2"
  },
  "sourceProject": {
    "name": "fabrikam-fiber-tfvc",
    "url": "https://mytfsserver/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
  },
  "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/cloneOperation/3"
}

Clone test plan

POST https://{instance}/DefaultCollection/{project}/_apis/test/plans/{planId}/cloneOperation?api-version={version}
Content-Type: application/json
{
  "destinationTestPlan" : "Destination Test Plan",
  "options" : "Clone Options",
  "suiteIds" : "Suite IDs List"
}
Parameter Type Default Notes
URL
instance string TFS server name ({server:port}).
project string Name or ID of the project.
planId int ID of the test plan to be cloned
api-version string Version of the API to use.
Body
destinationTestPlan TestPlan Contains details of the destination plan. Name of the test plan must be provided. Project, area , iteration of the test plan are optional.
options CloneOptions Options for cloning can be passed. Clone options include : relatedLinkComment, copyAllSuites, copyAncestorHierarchy, destinationWorkItemType, cloneRequirements, overrideParameters.
suiteIds int[] List of all the suite IDs to be cloned inside the plan

Sample request

POST https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1/cloneOperation?api-version=3.0-preview.1
{
  "destinationTestPlan": {
    "name": "DestinationSuite",
    "Project": {
      "Name": "fabrikam-fiber-tfvc2"
    }
  },
  "options": {
    "copyAncestorHierarchy": true,
    "copyAllSuites": true,
    "overrideParameters": {
      "System.AreaPath": "fabrikam-fiber-tfvc2",
      "System.IterationPath": "fabrikam-fiber-tfvc2"
    }
  },
  "suiteIds": [
    2
  ]
}

Sample response

{
  "opId": 2,
  "creationDate": "0001-01-01T00:00:00",
  "completionDate": "0001-01-01T00:00:00",
  "state": "queued",
  "message": null,
  "cloneStatistics": null,
  "resultObjectType": "testPlan",
  "destinationObject": {
    "id": "18",
    "name": "DestinationPlan",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc2/_apis/test/Plans/18"
  },
  "sourceObject": {
    "id": "1",
    "name": "TestPlan1",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1"
  },
  "destinationPlan": {
    "id": "18",
    "name": "DestinationPlan",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc2/_apis/test/Plans/18"
  },
  "sourcePlan": {
    "id": "1",
    "name": "TestPlan1",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1"
  },
  "destinationProject": {
    "name": "fabrikam-fiber-tfvc2",
    "url": "https://mytfsserver/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc2"
  },
  "sourceProject": {
    "name": "fabrikam-fiber-tfvc",
    "url": "https://mytfsserver/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
  },
  "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/cloneOperation/2"
}

Get clone information

GET https://{instance}/DefaultCollection/{project}/_apis/test/cloneOperation/{operationId}?api-version={version}&$includeDetails={includeDetails}
Parameter Type Notes
URL
instance string TFS server name ({server:port}).
project string Name or ID of the project.
operationID int Operation ID returned when we queue a clone operation
Query
api-version string Version of the API to use.
includeDetails boolean If false returns only status of the clone operation information, if true returns complete clone information

Sample request

GET https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/cloneOperation/2?$includeDetails=true&api-version=3.0-preview.1

Sample response

{
  "opId": 2,
  "creationDate": "2015-12-22T08:41:39.403Z",
  "completionDate": "2015-12-22T08:41:40.49Z",
  "state": "succeeded",
  "message": null,
  "cloneStatistics": {
    "totalTestCasesCount": 7,
    "clonedTestCasesCount": 7,
    "clonedSharedStepsCount": 0,
    "totalRequirementsCount": 0,
    "clonedRequirementsCount": 0
  },
  "resultObjectType": "testPlan",
  "destinationObject": {
    "id": "18",
    "name": "DestinationPlan",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc2/_apis/test/Plans/18"
  },
  "sourceObject": {
    "id": "1",
    "name": "TestPlan1",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1"
  },
  "destinationPlan": {
    "id": "18",
    "name": "DestinationPlan",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc2/_apis/test/Plans/18"
  },
  "sourcePlan": {
    "id": "1",
    "name": "TestPlan1",
    "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/Plans/1"
  },
  "destinationProject": {
    "name": "fabrikam-fiber-tfvc2",
    "url": "https://mytfsserver/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc2"
  },
  "sourceProject": {
    "name": "fabrikam-fiber-tfvc",
    "url": "https://mytfsserver/DefaultCollection/_apis/projects/fabrikam-fiber-tfvc"
  },
  "url": "https://mytfsserver/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/cloneOperation/2"
}