移除、刪除或還原工作專案Remove, delete, or restore work items

Azure Boards |Azure DevOps Server 2020 |Azure DevOps Server 2019 |TFS 2018-TFS 2013Azure Boards | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 - TFS 2013

工作專案可以永遠存留在您的工作追蹤資料存放區中。Work items can live forever in your work tracking data store. 您永遠不需要將它們刪除。You never have to delete them. 不過,視您的商務需求而定,您可能會想要執行下列一或多個動作:However, depending on your business needs, you may want to perform one or more of these actions:

  • 變更狀態:只需將工作專案 狀態 變更為 [ 移除 ] 或 [ 下],即可移除待處理專案(backlog)和麵板上的工作專案。Change state: Remove work items from appearing on backlogs and boards by simply changing the work item State to Remove or Cut.
  • Delete:從待處理專案、面板和查詢中移除工作專案。Delete: Remove work items from backlogs, boards, and queries. 已刪除的工作專案會移至資源回收筒。Deleted work items are moved to a Recycle Bin. 您可以從資源回收筒還原或永久刪除它們。From the Recycle Bin you can restore or permanently delete them.
  • 終結 :永久 刪除工作專案,從工作追蹤資料存放區刪除所有資料。Destroy: Permanently delete work items, deleting all data from the work tracking data store.
  • 還原:復原已刪除的工作專案,從資源回收筒還原它們。Restore: Recover deleted work items, restoring them from the Recycle Bin.
  • 變更狀態:只需將工作專案 狀態 變更為 [ 移除 ] 或 [ 下],即可移除待處理專案(backlog)和麵板上的工作專案。Change state: Remove work items from appearing on backlogs and boards by simply changing the work item State to Remove or Cut.
  • 終結 :永久 刪除工作專案,從工作追蹤資料存放區刪除所有資料。Destroy: Permanently delete work items, deleting all data from the work tracking data store.

目前無法支援封存工作專案或專案的功能。The ability to archive work items or projects isn't a supported feature at this time.

注意

如需有關 Azure Artifacts 資源回收筒的詳細資訊,請參閱 刪除和復原套件For information about the Azure Artifacts Recycle Bin, see Delete and recover packages.

必要條件Prerequisites

  • 若要移除、修改或刪除工作專案,您必須是 [ Contributors ] 群組的成員,或將下列許可權設定為 [ 允許]。To remove, modify, or delete work items, you must be a member of the Contributors group or have the following permissions set to Allow.
    • 移除工作專案在此節點中顯示 View 工作專案 ,然後 編輯此節點 區域路徑許可權設定為 [ 允許] 的工作專案。Remove work items: Have the View work items in this node and Edit work items in this node Area Path permissions set to Allow.
    • 刪除工作專案還原工作專案:將 [ 刪除] 和 [還原工作專案 ] 專案層級許可權設為 [ 允許]。Delete work items and Restore work items: Have the Delete and restore work items project-level permission set to Allow. 此外,若要還原工作專案,您必須具有 基本 存取權或更高版本。Also, to restore work items, you must have Basic access or higher. 具有專案關係 存取權的使用者可以查看 資源回收筒 的內容,但無法還原或永久刪除 Bin 中的專案。Users with Stakeholder access can view the contents of the Recycle Bin, but can't restore or permanently delete items in the bin.
  • 若要移除、修改或刪除工作專案,您必須是 [ Contributors ] 群組的成員,或將下列許可權設定為 [ 允許]。To remove, modify, or delete work items, you must be a member of the Contributors group or have the following permissions set to Allow.
    • 移除工作專案在此節點中顯示 View 工作專案 ,然後 編輯此節點 區域路徑許可權設定為 [ 允許] 的工作專案。Remove work items: Have the View work items in this node and Edit work items in this node Area Path permissions set to Allow.
  • 若要 還原或終結工作專案,您必須是 專案系統管理員 群組的成員,或將此專案專案層級許可權中的 [ 刪除工作專案 ] 設為 [ 允許]。To Restore or destroy work items, you must be a member of the Project Administrators group or have the Delete work items in this project project-level permission set to Allow.
  • 若要 (WITADMIN CLI) 終結工作專案,您必須是 專案系統管理員 群組的成員,或將此專案專案層級許可權中的 [ 刪除工作專案 ] 設為 [ 允許]。To Destroy work items (witadmin CLI), you must be a member of the Project Administrators group or have the Delete work items in this project project-level permission set to Allow.

注意

根據預設,對於 TFS 2015.1 和較早的版本,Contributors 群組會將 這個專案中的工作專案集刪除 為 [ 未設定]。By default, for TFS 2015.1 and earlier versions, the Contributors group has Delete work items in this project set to Not set. 這項設定會讓 Contributors 群組繼承明確設定其最接近父系的值。This setting causes the Contributors group to inherit the value from the closest parent that has it explicitly set.

如需指派給內建組之許可權的簡化觀點,請參閱 許可權和存取權For a simplified view of permissions assigned to built-in groups, see Permissions and access.

注意

具有公用專案之專案關係 存取權的使用者,可以完整存取所有的工作追蹤功能,就像具有 基本 存取權的使用者一樣。Users with Stakeholder access for a public project have full access to all work tracking features just like users with Basic access. 如需詳細資訊,請參閱 關於存取層級For details, see About access levels.

重要

從 Azure DevOps 內容版本選取器中選取版本。

若要查看您的平臺可用的內容,請確定您是從位於目錄上方的版本選取器中選取正確的文章版本。To view the content available for your platform, make sure that you select the correct version of this article from the version selector which is located above the table of contents. 功能支援會因您是從 Azure DevOps Services 或 Azure DevOps Server 的內部部署版本(從 Team Foundation Server (TFS) 重新命名而定)而有所不同。Feature support differs depending on whether you are working from Azure DevOps Services or an on-premises version of Azure DevOps Server, renamed from Team Foundation Server (TFS).
若要瞭解您使用的內部部署版本,請參閱 我所使用的平臺/版本為何?To learn which on-premises version you are using, see What platform/version am I using?

移除或刪除多個工作專案Remove or delete multiple work items

您可以對個別工作專案執行作業,或大量修改數個工作專案。You can perform operations on individual work items or bulk modify several work items.

從入口網站中,您可以從 [待處理專案] 或 [查詢結果] 頁面選取數個工作專案,並使用相關聯的功能執行大量更新。From the web portal, you can multi-select several work items from a backlog or query results page and perform a bulk update using the associated feature. 若要同時刪除或還原數個工作專案,請參閱 大量修改工作專案To delete or restore several work items at the same time, see Bulk modify work items.

移除工作專案Remove work items

藉由將工作專案的 狀態 變更為 [ 已移除],您可以有效地將它從待處理專案或面板視圖中移除 (產品、組合和短期衝刺待處理專案、儀表板和工作面板) 。By changing the State of a work item to Removed, you effectively remove it from a backlog or board view (product, portfolio, and sprint backlogs, Kanban board, and taskboards). 移除 的狀態會對應到 已移除 的工作流程類別狀態。The Removed state corresponds to the Removed workflow category state. 如果您定義自訂工作流程狀態,您對應至 已移除 工作流程類別狀態的任何狀態都將以類似的方式運作。If you define custom workflow states, any state you map to the Removed workflow category state will act in a similar way.

將狀態變更為已移除Change State to Removed

若要讓移除的專案不會顯示在查詢中,您必須加入一個子句來篩選 [ 狀態 ] 欄位。To cause removed items to not show up in queries, you must add a clause that filters on the State field.

注意

基本進程不支援 已移除 的狀態。The Removed state isn't supported with the Basic process. 只有 Agile、Scrum 和 CMMI 流程工作專案類型才支援此功能。It is only supported with the Agile, Scrum, and CMMI process work item types. 當您將專案新增至 Azure DevOps Services 或 Azure DevOps Server 2019 Update 1時,就可以使用基本程式。The Basic process is available when you add a project to Azure DevOps Services or Azure DevOps Server 2019 Update 1.

刪除工作專案Delete work items

刪除的工作專案不會出現在您的待處理專案(backlog)、面板或查詢中。Deleted work items won't appear in your backlogs, boards, or queries. 您可以視需要將已刪除的專案移至 資源回收筒 ,以從中復原。Deleted items are moved to a Recycle Bin from which you can recover them if needed. 若要刪除測試案例、測試計劃或測試套件,或其他與測試相關的工作專案類型,請參閱 刪除測試成品。To delete a test case, test plan, or test suite, or other test-related work item types, see Delete test artifacts.

  1. 您可以從工作專案表單中刪除工作專案,方法是從 [待處理專案] 或 [查詢結果] 頁面中選取 [工作專案],或從 [儀表板] 或 [工作面板]。You can delete a work item from within the work item form, by multi-selecting work items from a backlog or query results page, or from a Kanban board or taskboard.

    若要刪除單一工作專案,請開啟工作專案,選擇 [ 動作] 圖示,然後選取 [ 刪除]。

    工作專案表單,動作功能表,刪除work item form, actions menu, Delete
    若要刪除數個工作專案,請 從待處理專案或查詢結果清單進行多重選取 ,然後選擇 [ 動作] 圖示並選取 [ 刪除]。

    工作專案清單、動作功能表、刪除List of work items, actions menu, Delete

    若要從您的看板或工作面板刪除工作專案,請選擇卡片的 [ 動作] 圖示,然後選取 [ 刪除]。

    從儀表板面板刪除工作專案Delete work item from Kanban board

  2. 確認您想要實際刪除 (s) 的專案。Confirm you want to actually delete the item(s).

    確認刪除對話方塊Confirm delete dialog

注意

您可以從 TFS 2015.2 和更新版本取得 刪除和回收站 功能。The Delete and Recycle bin features are available from TFS 2015.2 and later versions.

  1. 您可以從工作專案表單中刪除工作專案,或從 [待處理專案] 或 [查詢結果] 頁面中選取多個工作專案。You can delete a work item from within the work item form, or by multi-selecting work items from a backlog or query results page.

    若要刪除單一工作專案,請開啟工作專案,選擇 [ 動作] 圖示,然後選取 [ 刪除]。

    工作專案表單,動作功能表,刪除work item form, actions menu, Delete

    若要刪除數個工作專案,請 從待處理專案或查詢結果清單進行多重選取 ,然後選擇 [ 動作] 圖示並選取 [ 刪除]。

    工作專案清單、動作功能表、刪除List of work items, actions menu, Delete

    您也可以刪除您的看板或工作面板中的工作專案。You can also delete work items from your Kanban or taskboard.

    從儀表板面板刪除工作專案

    或者,您可以將它們拖曳到  回收站 (回收站) 。Or, you can drag them to the Recycle bin (Recycle bin). 您只能從 工作 中樞存取 (回收站) 。You can only access the (Recycle bin) from the Work hub.

  2. 確認您想要實際刪除 (s) 的專案。Confirm you want to actually delete the item(s).

    確認刪除對話方塊

    注意

    內部部署 Azure DevOps 的 [刪除工作專案確認] 對話方塊可能會指出 (停用) 停用自動刪除設定。The Delete work items confirmation dialog for on-premises Azure DevOps may indicate there are auto-delete settings (disabled). 沒有您可以啟用或停用的設定。There are no settings you can enable or disable. 只有背景進程會永久刪除已設定為刪除的工作專案。There is only a background process which permanently deletes work items that have been set to delete.

還原或終結工作專案Restore or destroy work items

您可以還原已刪除的工作專案,或從入口網站資源回收筒永久刪除工作專案。You restore deleted work items or permanently delete them from the web portal Recycle Bin.

  1. 選擇 [面板] >工作專案 ],然後選擇 [ 資源回收筒]。Choose Boards>Work Items and then choose the Recycle Bin.

    ![面板>工作專案] 頁面上,開啟 [回收站]](media/move-change-delete/open-recycle-bin-new-nav.png)Boards>Work Items page, Open Recycle bin

    如果您沒有看到 [資源回收筒] 選項,請選擇 [更多命令 … ],然後從選項的功能表中選擇。If you don't see the Recycle Bin option, choose More commands … and choose it from the menu of options.

    注意

    刪除的測試成品不會出現在 資源回收筒 中,而且無法還原。Deleted test artifacts won't appear in the Recycle Bin and can't be restored. 刪除測試成品不只會刪除選取的測試成品,也會刪除其所有相關聯的子專案,例如子測試套件、跨所有設定的測試點、 (基礎測試案例工作專案的測試人員不會被刪除) 、測試結果歷程記錄和其他相關聯的歷程記錄。Deletion of test artifacts not only deletes the selected test artifact but also all its associated child items such as child test suites, test points across all configurations, testers (the underlying test case work item doesn't get deleted), test results history, and other associated history.

  2. 新的瀏覽器索引標籤隨即開啟,其中包含的查詢會列出新增至資源回收筒的工作專案。A new browser tab opens with the query which lists work items added to the Recycle Bin.

  3. 選取您要還原的專案,然後選擇 [ 還原]。Select the items you want to restore and then choose Restore.
    還原選取的專案Restore selected items

    (選擇性)您可以選擇永久刪除專案。Optionally, you can choose to permanently delete the items.

    注意

    您無法開啟已移至 資源回收筒 的工作專案。You can't open work items that have been moved to the Recycle Bin. 此外,如果您的 [永久刪除工作專案] 專案層級許可權設定為 [允許],則只會看到 [永久刪除] 選項Also, you'll only see the Permanently delete option if your Permanently delete work items project-level permission is set to Allow.

  4. 確認您的選擇。Confirm your selection.

您可以從入口網站 資源回收筒 還原已刪除的工作專案。You restore deleted work items from the web portal Recycle Bin.

注意

[ 刪除 ] 和 [ 資源回收筒 ] 功能需要 TFS 2015.2 或更新版本。The Delete and Recycle Bin features require TFS 2015.2 or later version.

  1. 選擇 [ 工作>待處理 專案] 或 [ >查詢 ],然後選擇 資源回收筒Choose Work>Backlog s or Work>Queries and then choose the Recycle Bin.

    開啟回收站

    新的瀏覽器索引標籤隨即開啟,其中包含的查詢會列出新增至 資源回收筒 的工作專案。A new browser tab opens with the query which lists work items added to the Recycle Bin.

  2. 選取您要還原的專案,然後選擇 [ 還原]。Select the items you want to restore and then choose Restore.

    還原選取的專案

    (選擇性)您可以選擇永久刪除專案。Optionally, you can choose to permanently delete the items.

    注意

    您無法開啟已移至 資源回收筒 的工作專案。You can't open work items that have been moved to the Recycle Bin. 此外,如果您的 [永久刪除工作專案] 專案層級許可權設定為 [允許],則只會看到 [永久刪除] 選項Also, you'll only see the Permanently delete option if your Permanently delete work items project-level permission is set to Allow.

  3. 確認您的選擇。Confirm your selection.

(命令列刪除或摧毀工作專案) Delete or destroy work items (command line)

您可以使用 az 電路板工作專案刪除 命令來刪除或終結工作專案。You can delete or destroy a work item with the az boards work-item delete command. 若要開始使用,請參閱 AZURE DEVOPS CLI 入門To get started, see Get started with Azure DevOps CLI.

注意

您可以還原您 刪除 的工作專案,但是無法還原您選擇要 終結的工作專案。You can restore work items you delete, but you can't restore work items you choose to destroy.

az boards work-item delete --id
                           [--destroy]
                           [--org]
                           [--project]
                           [--yes] 

參數Parameters

  • 識別碼:必要。id: Required. 工作專案的識別碼。The ID of the work item.
  • 終結 :選擇性destroy: Optional. 永久刪除此工作專案。Permanently delete this work item.
  • 組織: AZURE DEVOPS 組織 URL。org: Azure DevOps organization URL. 您可以使用設定預設組織 az devops configure -d organization=ORG_URLYou can configure the default organization using az devops configure -d organization=ORG_URL. 如果未設定為預設值或使用來挑選時,則為必要 git configRequired if not configured as default or picked up using git config. 範例: --org https://dev.azure.com/MyOrganizationName/.Example: --org https://dev.azure.com/MyOrganizationName/.
  • 專案:專案的名稱或識別碼。project: Name or ID of the project. 您可以使用來設定預設專案 az devops configure -d project=NAME_OR_IDYou can configure the default project using az devops configure -d project=NAME_OR_ID. 如果未設定為預設值或使用來挑選時,則為必要 git configRequired if not configured as default or picked up using git config.
  • :選擇性。yes: Optional. 不提示確認。Do not prompt for confirmation.

範例Example

下列命令會永久刪除識別碼為864的 bug,而不會提示您進行確認。The following command permanently deletes the bug with the ID 864 and doesn't prompt you for confirmation.

az boards work-item delete --id 864 --destroy --yes

終結工作專案 (命令列) Destroy work items (command line)

使用 witadmin destroywi 命令,將工作專案從資料存放區中永久移除。Use the witadmin destroywi command to permanently remove work items from the data store. 永久刪除表示工作追蹤資料存放區中的所有資訊都會刪除,而且無法還原或重新開機。A permanent delete means all information in the work tracking data store is deleted and cannot be restored nor reactivated.

注意

在 TFS 2018.2 和更新版本中,從 witadmin 命令列刪除工作專案已被取代,Azure Boards 的雲端服務則不支援。Deleting work items from the witadmin command line is deprecated for TFS 2018.2 and later versions, and not supported for Azure Boards cloud service.

開啟安裝最新版 Visual Studio 的 [命令提示字元] 視窗,並將目錄變更為已安裝 witadmin.exe 工具的位置。Open a Command Prompt window where the latest version of Visual Studio is installed and change the directory to where the witadmin.exe tool has been installed.

例如,您可以變更為 TFS 2018 的下列目錄。For example, you would change to the following directory for TFS 2018. (其他版本,請參閱 永久移除工作專案 (witadmin destroywi) ) 。(For other versions, see Remove work items permanently (witadmin destroywi)).

%programfiles(x86)%\Microsoft Visual Studio\2018\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer

例如,您可以變更為 TFS 2017 的下列目錄。For example, you would change to the following directory for TFS 2017. (其他版本,請參閱 永久移除工作專案 (witadmin destroywi) ) 。(For other versions, see Remove work items permanently (witadmin destroywi)).

%programfiles(x86)%\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer

例如,您可以變更為 TFS 2015 的下列目錄。For example, you would change to the following directory for TFS 2015. (其他版本,請參閱 永久移除工作專案 (witadmin destroywi) ) 。(For other versions, see Remove work items permanently (witadmin destroywi)).

cd %programfiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE

例如,您可以變更為 TFS 2013 的下列目錄。For example, you would change to the following directory for TFS 2013. (其他版本,請參閱 永久移除工作專案 (witadmin destroywi) ) 。(For other versions, see Remove work items permanently (witadmin destroywi)).

cd %programfiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE

在 Windows 32 位元版本中,將 %programfiles(x86)% 取代為 %programfiles%。On a 32-bit edition of Windows, replace %programfiles(x86)% with %programfiles%.

Witadmin 命令列工具會隨 Visual Studio 或 Team Explorer 的任何版本安裝。The witadmin command-line tool installs with any version of Visual Studio or Team Explorer. 您可以藉由安裝 免費版本的 Visual Studio Community來存取此工具。You can access this tool by installing the free version of Visual Studio Community.

  • 若要刪除數個工作專案,請輸入集合的伺服器名稱和目錄路徑。To delete several work items, enter the server name and directory path to the collection. 例如:For example:

    witadmin destroywi /collection:http://TFSServerName:8080/tfs/DefaultCollection /id:12,15,23
    
  • 若要刪除單一工作專案,請直接輸入識別碼,如下所示:To delete a single work item, simply enter the ID as shown:

    witadmin destroywi /collection:http://TFSServerName:8080/tfs/DefaultCollection /id:2003
    

Delete 和 restore 動作的運作方式How delete and restore actions work

當您刪除工作專案時,會發生下列動作:When you delete a work item, the following actions occur:

  • 產生工作專案的新修訂Generates a new revision of the work item
  • 依/變更日期 欄位更新變更,以支援可追蹤性Updates the Changed By/Changed Date fields to support traceability
  • 完全保留工作專案,包括所有欄位指派、附件、標記和連結Preserves the work item completely, including all field assignments, attachments, tags, and links
  • 導致工作專案變成不可查詢,因此不會出現在任何工作追蹤體驗、查詢結果或報表中Causes work item to become non-queryable and therefore won't appear in any work tracking experience, query result, or report
  • 據以更新圖表、CFD、速度、待執行工作和輕量圖表,以移除已刪除的工作專案Updates charts accordingly, CFD, velocity, burndown and lightweight charts are updated to remove deleted work items
  • 移除工作追蹤延伸模組Removes work tracking extensions
  • 保留最新值以外的趨勢資料Preserves trend data except for the latest value
  • 從資料倉儲/cube 移除工作專案,類似于永久移除。Removes the work item from the data warehouse/cube similar to as if it was permanently removed.

當您還原工作專案時,會發生下列動作:When you restore a work item, the following actions occur:

  • 會建立新的工作專案修訂Causes a new revision of the work item to be made
  • 依/變更日期 欄位更新變更,以支援可追蹤性Updates the Changed By/Changed Date fields to support traceability
  • 變成可查詢Becomes queryable
  • 所有欄位都保持不變All fields remain unchanged
  • 歷程記錄包含兩個新的修訂,一個用於刪除,另一個用於還原History contains two new revisions, one for deletion, and one for restore
  • 會重新連結工作追蹤延伸模組Reattaches work tracking extensions
  • 相應地更新圖表、CFD、速度、待執行工作和輕量圖表,以包含已還原的工作專案Updates charts accordingly, CFD, velocity, burndown and lightweight charts are updated to include the restored work items
  • 還原趨勢資料Restores trend data
  • 將工作專案新增回資料倉儲/cubeAdds the work item back to the data warehouse/cube
  • 如果先前的區域路徑或反復專案路徑已刪除,則將 [區域] 或 [反復專案路徑] 欄位設定為根節點。Sets the area or iteration path fields to the root node if the previous area path or iteration paths were deleted.

REST APIREST API

若要以程式設計方式刪除、還原和終結工作專案,請參閱下列其中一項 REST API 資源:To programmatically delete, restore, and destroy work items, see one of the following REST API resources: