简体   繁体   中英

How to Change TFS WIT via PowerShell

I have PowerShell code that exports my Bug and Test Cases WIT's into a folder, but I want to add new data to the XML. So I would want to add a new version number each time but not remove any of the existing data eg Next version is 1.1.0.2205. I already have the code to import the WIT but this is where I am struggling. Any help would be much appreciated

Here is how the Bug WIT looks like and where I want to add the data:

<FIELD name="Detected in Version" refname="Example.DetectedInVersion" type="String" reportable="dimension">
    <SUGGESTEDVALUES expanditems="true">
      <LISTITEM value="1.2107.0.0" />
      <LISTITEM value="1.2201.0.0" />
      <LISTITEM value="1.1.0.2202" />
      <LISTITEM value="1.1.0.2203" />
      <LISTITEM value="1.1.0.2204" />
    </SUGGESTEDVALUES>
    <REQUIRED />
  </FIELD>

I would avoid changing the WIT every type, use a GlobalList instead. Your definition becomes

<FIELD name="Detected in Version" refname="Example.DetectedInVersion" type="String" reportable="dimension">
    <SUGGESTEDVALUES expanditems="true">
      <GLOBALLIST name="MyListOfVersions" />
    </SUGGESTEDVALUES>
    <REQUIRED />
  </FIELD>

the global list is defined in another XML file like this

<?xml version="1.0" encoding="utf-8"?>
<gl:GLOBALLISTS xmlns:gl="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/globallists">
  <GLOBALLIST name="MyListOfVersions">
      <LISTITEM value="1.2107.0.0" />
      <LISTITEM value="1.2201.0.0" />
      <LISTITEM value="1.1.0.2202" />
      <LISTITEM value="1.1.0.2203" />
      <LISTITEM value="1.1.0.2204" />
  </GLOBALLIST>
</gl:GLOBALLISTS>

and imported using a command like

witadmin importgloballist /collection:http://your_tfs_server:8080/tfs/DefaultCollection /f:MyListOfVersionsGlobalLists.xml

Now it is easy to edit this list without changing the definition. You can re-run the same command altering the file's content, or, if you prefer pure Powershell code, look at Adding to a GlobalList

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM