{"id":87031,"date":"2020-09-09T12:00:19","date_gmt":"2020-09-09T19:00:19","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/scripting\/?p=87031"},"modified":"2020-09-08T13:46:21","modified_gmt":"2020-09-08T20:46:21","slug":"import-azure-devops-test-plans-from-one-environment-to-another","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/import-azure-devops-test-plans-from-one-environment-to-another\/","title":{"rendered":"Import Azure DevOps Test Plans from One Environment to Another"},"content":{"rendered":"<p><strong>Summary<\/strong> Standardization of Azure DevOps Test Plans and Reusing Them Between Different Organizations<\/p>\n<p>Today we introduce Claudia Ferguson and Mike Stiers to the Scripting Blog. Claudia is a Senior Consultant with the Microsoft Active Directory Migration Services Engineer team, and Mike Stiers is a Microsoft Consultant from Toronto Canada. His focus is to help teams to use scalable infrastructure as code deployments in Azure DevOps. They put together something you will find to be very useful when you need to move DevOps test plans. There is some PowerShell here too (as it&#8217;s the Scripting Blog!) but the content is just too cool to not share out!<\/p>\n<p>Claudia and Mike, the Blog is yours today!<\/p>\n<p>Thanks Dr. Scripto! Today we will be discussing moving a DevOps test case into another environment of Azure.<\/p>\n<p>We will use the process below to export Test Cases with Shared Steps from the \u201cTemplate\u201d SOURCE project into the different DevOps Organization and new project. This process can be used to import Test plans into a new DevOps Organization as well as just a separate DevOps project. It is recommended to have a separate project for each customer and a separate project where you will maintain a template for the test plans.<\/p>\n<h4>General description<\/h4>\n<p>Export\/Import shared steps by using Export and Import CSV option. (Reference link: <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/boards\/queries\/import-work-items-from-csv?view=azure-devops\">https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/boards\/queries\/import-work-items-from-csv?view=azure-devops<\/a>)<\/p>\n<p style=\"text-align: left; padding-left: 40px;\"><strong>NOTE<\/strong>:<\/p>\n<p style=\"text-align: left; padding-left: 40px;\">This is a known issue with Shared Steps so you will not be able to follow usual process for exporting parent\/child relationship like you can do with other work items such as Epic\/Feature\/UserStory where you can just export all of them at once into one csv.<\/p>\n<p style=\"text-align: left; padding-left: 40px;\">You will need to export separately Shared Steps and Test Cases in two separate csv files.<\/p>\n<h4 style=\"text-align: left;\">Export <strong>Shared Steps<\/strong> into csv file from SOURCE DevOps<\/h4>\n<p>1. Export all <strong>Shared steps<\/strong> by using custom query as shown in the screenshot below.<\/p>\n<ul>\n<li>Click on Boards -&gt; Query<\/li>\n<li>Under Queries, select All<\/li>\n<li>Click on New Query<\/li>\n<li>Create \u201cShared Steps Only\u201d Query as shown below<\/li>\n<\/ul>\n<p style=\"padding-left: 40px;\"><strong>NOTE<\/strong>: <span style=\"font-size: 1rem;\">You will need to add an additional column \u201cSteps\u201d in the query<\/span><\/p>\n<ul>\n<li>Click on \u201cColumn options\u201d in the query Editor, and then add \u201cSteps\u201d column.<\/li>\n<li>Save the query \u201cShared Steps Only\u201d<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87025\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items.jpg\" alt=\"Image items\" width=\"1396\" height=\"342\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items.jpg 1396w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-300x73.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-1024x251.jpg 1024w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-768x188.jpg 768w\" sizes=\"(max-width: 1396px) 100vw, 1396px\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87024\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-1.jpg\" alt=\"Image items 1\" width=\"660\" height=\"689\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-1.jpg 660w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-1-287x300.jpg 287w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87023\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-2.jpg\" alt=\"Image items 2\" width=\"924\" height=\"602\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-2.jpg 924w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-2-300x195.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-2-768x500.jpg 768w\" sizes=\"(max-width: 924px) 100vw, 924px\" \/><\/p>\n<p>2. Click on \u201cShared Steps Only\u201d query and then click Run query.<\/p>\n<p>3. Export the results of the query to CSV by clicking \u201cExport to CSV\u201d option<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87022\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-3.jpg\" alt=\"Image items 3\" width=\"1639\" height=\"175\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-3.jpg 1639w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-3-300x32.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-3-1024x109.jpg 1024w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-3-768x82.jpg 768w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-3-1536x164.jpg 1536w\" sizes=\"(max-width: 1639px) 100vw, 1639px\" \/><\/p>\n<p>4. Edit shared steps spreadsheet. Rename ID column to Description<\/p>\n<h4><\/h4>\n<h4>Import <strong>Shared Steps<\/strong> into <strong>TARGET<\/strong> DevOps<\/h4>\n<p>5. Import Shared steps that you just modified<\/p>\n<ul>\n<li>Click on Boards -&gt; Query -&gt; Import Work Items<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87021\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-4.jpg\" alt=\"Image items 4\" width=\"770\" height=\"234\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-4.jpg 770w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-4-300x91.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-4-768x233.jpg 768w\" sizes=\"(max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>6. Click Save Items<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87020\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-5.jpg\" alt=\"Image items 5\" width=\"835\" height=\"393\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-5.jpg 835w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-5-300x141.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-5-768x361.jpg 768w\" sizes=\"(max-width: 835px) 100vw, 835px\" \/><\/p>\n<p style=\"padding-left: 40px;\"><strong>NOTE<\/strong>: <span style=\"font-size: 1rem;\">Description column will have old IDs and ID column will have new IDs<\/span><\/p>\n<p>7. Export to CSV with new IDs. Name the export file <strong>SharedStepsReady.csv<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h4>Export <strong>Test Cases<\/strong> from the <strong>SOURCE<\/strong> DevOps<\/h4>\n<p>8. Export <strong>Test Cases<\/strong> into csv file <strong>\u201cTestCaseswithStepsIDsColumn.csv\u201d<\/strong><\/p>\n<ul>\n<li>Click on Boards -&gt; Query<\/li>\n<li>Under Queries, select ALL<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87019\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-6.jpg\" alt=\"Image items 6\" width=\"1438\" height=\"573\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-6.jpg 1438w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-6-300x120.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-6-1024x408.jpg 1024w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-6-768x306.jpg 768w\" sizes=\"(max-width: 1438px) 100vw, 1438px\" \/><\/p>\n<p><strong>NOTE<\/strong>: You will need to add an additional column \u201cSteps\u201d in the query as shown below<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87018\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-7.jpg\" alt=\"Image items 7\" width=\"660\" height=\"689\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-7.jpg 660w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-7-287x300.jpg 287w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/p>\n<p>9. Run PowerShell Script that we are providing. The new file should be created by PowerShell and called <strong>replaced.csv<\/strong><\/p>\n<p>10. Script for download<\/p>\n<pre class=\"prettyprint\">&lt;#\r\nReference:\r\nhttps:\/\/docs.microsoft.com\/en-us\/azure\/devops\/boards\/queries\/import-work-items-from-csv?view=azure-devops\r\n\r\nPrerequisites:\r\n-You will need to export all shared steps and test cases as two separate files from SOURCE DevOps\r\n\r\nShared Steps\r\n-Export all Shared steps\r\n-Edit shared steps spreadsheet. Rename ID column to Description\r\n-Import Shared Steps into TARGET DevOps\r\n-Click Save Items\r\n\r\n-From TARGET DevOps export all shared steps to CSV with new IDs. Name the export file SharedStepsReady.csv\r\n\r\nTest Cases\r\n-Export all Test Cases\r\n-From SOURCE DevOps export all Test Cases into csv file \"TestCaseswithStepsIDsColumn.csv\"\r\n\r\n-Run PowerShell Script. The new file should be exported called replaced.csv\r\n-Delete the ID column in the test cases spreadsheet\r\n-Import test cases csv\r\n#&gt;\r\n\r\n$sharedStepsCSV = \"SharedStepsReady.csv\"\r\n$testCasesCSV = \"TestCaseswithStepsIDsColumn.csv\"\r\n\r\n$sharedSteps = import-csv $sharedStepsCSV\r\n\r\n$testCases = Get-Content $testCasesCSV\r\n$sharedStepsHash = @{}\r\nForeach ($sharedStep in $sharedSteps)\r\n{\r\n$newID = $sharedStep.id\r\n$oldID = $sharedStep.description\r\n$sharedStepsHash.add($oldID,$newID)\r\n}\r\n\r\nForeach ($hash in $sharedStepsHash.GetEnumerator()) {\r\n$testCases = $testCases -replace $hash.Name, $hash.Value\r\n$hash.Name + \" \" + $hash.Value\r\n}\r\nSet-Content -Path replaced.csv -Value $testCases<\/pre>\n<p>11. Delete the ID column in the test cases spreadsheet called <strong>replaced.csv<\/strong> and save it without IDs column<\/p>\n<p>&nbsp;<\/p>\n<h4>Import <strong>Test Cases<\/strong> into <strong>TARGET<\/strong> DevOps<\/h4>\n<p>12. Import test cases csv that you just saved called <strong>replaced.csv<\/strong><\/p>\n<p>13. Once you imported all the work items, create a new Test Plan in the TARGET DevOps<\/p>\n<p>14. Click on the Define Tab, then New Test Case, and select Add Existing Test Cases<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87017\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-8.jpg\" alt=\"Image items 8\" width=\"753\" height=\"684\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-8.jpg 753w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-8-300x273.jpg 300w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><\/p>\n<p>15. Click Run a Query, then select all the test cases and click Add Test Cases<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-87016\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-9.jpg\" alt=\"Image items 9\" width=\"1080\" height=\"542\" srcset=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-9.jpg 1080w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-9-300x151.jpg 300w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-9-1024x514.jpg 1024w, https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2020\/08\/items-9-768x385.jpg 768w\" sizes=\"(max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Your good friend, Doctor Scripto<\/strong><\/p>\n<p>PowerShell, Azure, Doctor Scripto, Claudia Ferguson, Mike Stiers<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary Standardization of Azure DevOps Test Plans and Reusing Them Between Different Organizations Today we introduce Claudia Ferguson and Mike Stiers to the Scripting Blog. Claudia is a Senior Consultant with the Microsoft Active Directory Migration Services Engineer team, and Mike Stiers is a Microsoft Consultant from Toronto Canada. His focus is to help teams [&hellip;]<\/p>\n","protected":false},"author":33024,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[759,1738],"tags":[476,2848,1740,2849,377],"class_list":["post-87031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-powershell","tag-azure","tag-claudia-ferguson","tag-doctor-scripto","tag-mike-stiers","tag-powershell"],"acf":[],"blog_post_summary":"<p>Summary Standardization of Azure DevOps Test Plans and Reusing Them Between Different Organizations Today we introduce Claudia Ferguson and Mike Stiers to the Scripting Blog. Claudia is a Senior Consultant with the Microsoft Active Directory Migration Services Engineer team, and Mike Stiers is a Microsoft Consultant from Toronto Canada. His focus is to help teams [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/87031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/33024"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=87031"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/87031\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=87031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=87031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=87031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}