[TFS2010] HowTo: Eliminar un WorkItem

image47dd1de4

Buenas,

eliminar un WorkItem no es una tarea que sea de las más recomendadas. Principalmente porque si has creado un WI que no es útil, es decir te has equivocado, pues quien te dice que no te equivoques y elimines un WI que no es el correcto. Asi que sobre estas bases, nuestros amigos de Redmond habían escondido esta opción muy dentro de las tripas de TFS y hasta las power tools de TFS2008, no teníamos opción de eliminar un WI.

En Team Foundation Server 2010 se ha incorporado una nueva herramienta llamada WitAdmin que entre otras cosas nos permite eliminar un WorkItem desde la línea de comandos con la siguiente sintaxis:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE>witadmin.exe destroywi /collection:http://<tfs>:8080/tfs/<tpc> /id:<WorkItemId>

donde <tfs> es el nombre de nuestro server, <tpc> es la Team Project Collection sobre la que trabajaremos y finalmente <WorkItemId> es el id del WI que se desea eliminar.

Además de poder eliminar un WI, estas son otras opciones que provee la herramienta:

  • changefield

      Changes properties of the field.

      Usage: witadmin changefield /s server /n typename [/name newname]
      [/syncnamechanges true|false] [/noprompt]

      /s                               Specifies the Team Foundation application-tier server. Either use the application-tier server name, or a fully
                                         specified URL such as http://tfs:8080.
      /n                              The reference name of the field.
      /name                        The new name of the field.
      /syncnamechanges    Indicates whether or not the field’s values should be
                                        updated in response to identity name changes.
      /noprompt                Turns off the confirmation message.

  • deactivatelinktype

      Deactivates the specified link type.  Users will no longer be able to create
      new links with this type. Existing links of this type will continue to function
      correctly.

      Usage: witadmin deactivatelinktype /s server /n typename

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /n    Specifies the link type to deactivate using either the link type name
             or reference name.

  • deletefield

      Deletes the specified field using the reference name.

      Usage: witadmin deletefield /s server /n typename [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /n           Specifies the reference name of the field to be deleted.
      /noprompt    Turns off the confirmation message.

  • deletelinktype

      Deletes the specified link type from the specified server.

      Usage: witadmin deletelinktype /s server /n typename [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /n           Specifies the link type to delete. The link type name or
                    reference name can be used.
      /noprompt    Turns off the confirmation message.

  • destroygloballist

      Destroys a global list.

      Usage: witadmin destroygloballist /s server /n typename [/noprompt] [/force]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /n           Specifies the name of the global list to destroy.
      /noprompt    Turns off the confirmation message.
      /force       Turns off validation that the an item is not in use before being
                    destroyed.

  • destroywi

      Destroys a work item or work items.  Currently, work items can only be
      destroyed.  Destroying a work item means the work item is physically deleted
      and cannot be restored.  The system does not support logical (and thus
      recoverable) deletion of work items.

      Usage: witadmin destroywi /s server /id id [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /id          Specifies the ID of the work item to destroy.  Supports multiple
                    IDs delimited by commas such as 12,15,23 (with no whitespace).
      /noprompt    Turns off the confirmation message.

  • destroywitd

      Destroys a work item type.  Currently, work item types can only be destroyed.
      Destroying a work item type means that work items of that type are physically
      deleted and cannot be restored.  It does not support logical (and thus
      recoverable) delete of work item types.

      Usage: witadmin destroywitd /s server /p project /n typename [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /p           Specifies the name of the team project.
      /n           Specifies the name of the work item type to destroy.
      /noprompt    Turns off the confirmation message.

  • exportcategories

      Exports the XML definition of a project’s work item type categories.

      Usage: witadmin exportcategories /s server /p project [/f filename] [/e
      encoding]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /p    Specifies the name of the team project.
      /f    Specifies the destination file for exporting the work item type
             category XML. If not specified, the XML is output to the display.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.

  • exportgloballist

      Exports the XML definition of global lists defined on a Team Foundation
      Server.

      Usage: witadmin exportgloballist /s server [/f filename] [/e encoding]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /f    Specifies the destination file for exporting the global list XML. When
             it is not specified, the XML is output to the display.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.

  • exportlinktype

      Exports the XML definition of a link type.

      Usage: witadmin exportlinktype /s server [/n typename] [/f filename] [/e
      encoding]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /n    Specifies the name of the work item link type that is to be exported.
      /f    Specifies the destination file for exporting the link type XML. When it
             is not specified, the XML is output to the display.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.

  • exportwitd

      Exports the XML definition of a work item type.

      Usage: witadmin exportwitd /s server /p project /n typename [/f filename] [/e
      encoding] [/exportgloballists]

      /s                    Specifies the Team Foundation application-tier server.
                             Either use the application-tier server name, or a fully
                             specified URL such as http://tfs:8080.
      /p                    Specifies the name of the team project.
      /n                    Specifies the name of the work item type to export.
      /f                    Specifies the destination file for exporting the work
                             item type XML. If not specified, the XML is output to
                             the display.
      /e                    Specifies the name of the .NET Framework 2.0 encoding
                             used to import the XML.  For example, /e utf-7 will use
                             Unicode (UTF-7) encoding.  By default, encoding is
                             automatically detected when it is possible.  If the
                             encoding can not be detected automatically, UTF-8 is
                             used.
      /exportgloballists    Exports the definitions of referenced global lists.  If
                             not specified, global list definitions are omitted.

  • importcategories

      This command imports a work item type category XML file into a team project on
      a Team Foundation Server.  If a category with the same name already exists, the
      new category definition will overwrite the existing definition.  If the work
      item type does not already exist, a new category will be created.

      Usage: witadmin importcategories /s server /p project /f filename [/e
      encoding]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /p    Specifies the team project in which the categories are imported. 
      /f    Specifies the work item type category XML file to import.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.

  • importgloballist

      Imports global lists from an XML definition file onto a Team Foundation
      Server. If a global list that has the same name already exists, the imported
      definition will overwrite the existing definition.  If a global list does not
      already exist, a new one will be created.

      Usage: witadmin importgloballist /s server /f filename [/e encoding]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /f    Specifies the global list XML definition file to be imported.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.

  • importlinktype

      Imports a link type XML definition file into Team Foundation Server. If a link
      type with the same reference name already exists, it will be updated to match
      the imported link type. If the link type does not already exist, a new link
      type will be created.

      Usage: witadmin importlinktype /s server /f filename [/e encoding] [/v]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /f    Specifies the file that contains the link type XML to import.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.
      /v    Validates the work item type or link type XML without importing it.

  • importwitd

      This command imports a work item type XML definition file into a team project
      on a Team Foundation Server.  If a work item type with the same name already
      exists, the new work item type definition will overwrite the existing
      definition. If the work item type does not already exist, a new work item type
      will be created.

      Usage: witadmin importwitd /s server [/p project] /f filename [/e encoding]
      [/v]

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /p    Specifies the team project in which the new work item type is imported.
             This is required, except when the validation-only option is used.
      /f    Specifies the work item type XML definition file to import.
      /e    Specifies the name of the .NET Framework 2.0 encoding used to import
             the XML.  For example, /e utf-7 will use Unicode (UTF-7) encoding.  By
             default, encoding is automatically detected when it is possible.  If the
             encoding can not be detected automatically, UTF-8 is used.
      /v    Validates the work item type or link type XML without importing it.

  • indexfield

      This command turns indexing for a field on or off.

      Usage: witadmin indexfield /s server /n name /index on|off

      /s        Specifies the Team Foundation application-tier server. Either use
                 the application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /n        The reference name of the field whose indexing information will be
                 updated.
      /index    Specifies whether the field should be indexed.

  • listfields

      Shows field information. By default, this lists all fields on the Team
      Foundation Server. Optional parameters can be used to list only specific
      fields.

      Usage: witadmin listfields /s server [/n typename] [/unused]

      /s         Specifies the Team Foundation application-tier server. Either use
                  the application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /n         The reference name of the field to display.
      /unused    Shows all fields that are not being used on the Team Foundation
                  Server.

  • listgloballist

      Lists the names of the global lists on a server.

      Usage: witadmin listgloballist /s server

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
             http://tfs:8080.

  • listlinktypes

      Lists the available set of link types on a server.

      Usage: witadmin listlinktypes /s server

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
             http://tfs:8080.

  • listwitd

      Lists the names of the work item types in the given project.

      Usage: witadmin listwitd /s server /p project

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /p    Specifies the name of the team project.

  • reactivatelinktype

      Activates the specified link type.  Users will be able to create new links
      with this type.

      Usage: witadmin reactivatelinktype /s server /n typename

      /s    Specifies the Team Foundation application-tier server. Either use the
             application-tier server name, or a fully specified URL such as
      http://tfs:8080.
      /n    Specifies the link type to activate using either the name or reference
             name.

  • rebuildcache

      This command invalidates cached data about work item types on all clients.
      Each client will refresh its cache the next time that it connects to the
      server. To avoid server performance issues, you should not run this command
      during typical operating hours.

      Usage: witadmin rebuildcache /s server [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /noprompt    Turns off the confirmation message.

  • renamewitd

      Renames an existing work item type.  Changes the display name of a work item
      type within a specific project.  Also, the work items of that type are updated
      to reflect the new work item type name.

      Usage: witadmin renamewitd /s server /p project /n typename /new newname
      [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /p           Specifies the name of the team project.
      /n           Specifies the name of the work item type to rename.
      /new         Specifies the new name for the work item type.
      /noprompt    Turns off the confirmation message.

  • reportfield

      Specifies whether and how the field is included in the data warehouse for
      reporting. For more information about how to use fields for reporting, see
      http://go.microsoft.com/fwlink/?LinkId=78060.

      Usage: witadmin reportfield /s server /n typename /t type [/formula formula]
      [/noprompt]

      /s           Specifies the Team Foundation application-tier server. Either
                    use the application-tier server name, or a fully specified URL
                    such as http://tfs:8080.
      /n           Reference name of the field.
      /t           Specifies how the field is used in the warehouse for reporting
                    (dimension, detail, measure, disable).
      /formula     Specifies a formula when the field is reported as a measure. The
                    only supported formula is sum.
      /noprompt    Turns off the confirmation message.

Saludos @ Alicante

El Bruno

   

Referencias WitAdmin: http://blogs.microsoft.co.il/blogs/shair/archive/2009/05/20/visual-studio-2010-witadmin-command-line-utility-commands.aspx

3 thoughts on “[TFS2010] HowTo: Eliminar un WorkItem

  1. Hola como estan?
    Tengo una pregunta y queria ver si me tiran un par de tips.

    Quiero guardar la informacion de los WI que sean borrados, antes de que sean borrados. Por si alguna vez se comete el error de eliminar un WI que no debia ser eliminado, se lo pueda recuperar de alguna manera.

    Con un amigo estabamos pensando en generar un BackUp diario, y luego compararlo con el del dia anterior, si los id de los WI no son consecutivos significa que fueron borrados, entonces restaurariamos toda la informacion referida a ese WI del backup del dia anterior.

    Muchas Gracias! Saludos!
    Muy muy bueno el Material!

    Like

    1. Esteban buenas,

      antes de responder te hago una pregunta, ¿porqué borran los WIs? no es una tarea trivial (solo se hace desde el command prompt) y tampoco es muy aconsejable.
      Con respecto a lo que preguntas, puede ser una buena opción lo de seguir los nros consecutivos, pero si tienes Shared Steps, bugs generados por builds, etc.; tal vez el modelo no se muy robusto. Una opción podría ser tener una generación diaria de los Ids de los WIs q estan activos y comparar el proceso diariamente con los WIs de los ultimos 10 días por ejemplo. Simple y no muy pesado.

      Saludos

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.