將 GitHub 認可、提取要求和問題連結至工作專案Link GitHub commits, pull requests, and issues to work items

Azure Boards |Azure DevOps Server 2020 |Azure DevOps Server 2019Azure Boards | Azure DevOps Server 2020 | Azure DevOps Server 2019

使用 GitHub 搭配 Azure Boards 時,您可以輕鬆地將所有工作保持連線。When using GitHub with Azure Boards, it's easy to keep all of your work connected. 您可以使用 GitHub 使用者或 Azure Boards 工作專案中熟悉的 #mention 語法來新增連結。Links can be added using the #mention syntax familiar to GitHub users or from the Azure Boards work item.

注意

Azure Boards 與 Azure DevOps Services 支援與 GitHub.com 和 GitHub Enterprise Server 存放庫整合。Azure Boards and Azure DevOps Services support integration with GitHub.com and GitHub Enterprise Server repositories.

內部部署 Azure DevOps 伺服器支援與 GitHub Enterprise Server 存放庫整合。On-premises Azure DevOps Servers support integration with GitHub Enterprise Server repositories.

必要條件Prerequisites

  • 您的 Azure Boards 專案必須連接到 GitHub 存放庫,您想要將其連結到其中的認可和提取要求都存在。Your Azure Boards project must be connected to the GitHub repository where the commits and pull requests you want to link to/from exist. 如需詳細資訊,請參閱 將 Azure Boards 連接到 GitHubFor details, see Connect Azure Boards to GitHub.
  • 您必須是參與者才能 Azure Boards。You must be a Contributor to Azure Boards.
  • 您必須是 GitHub 存放庫的參與者。You must be a Contributor to the GitHub repository.
  • 如果您的組織使用託管的 XML 程式模型來自訂工作追蹤體驗,您將需要更新工作專案類型,以連結至工作專案表單中的 [開發] 區段,並從該專案查看 GitHub 連結類型。If your organization uses the Hosted XML process model to customize the work tracking experience, you'll need to update the work item types to link to and view the GitHub link types from the Development section in the work item form. 如需詳細資訊,請參閱 更新選取工作專案類型的 XML 定義For details, see Update XML definitions for select work item types.

從 GitHub 認可、提取要求或問題,使用下列語法來建立 Azure Boards 工作專案的連結。From a GitHub commit, pull request or issue, use the following syntax to create a link to your Azure Boards work item. AB#ID 認可訊息的文字內輸入。Enter the AB#ID within the text of a commit message. 或者,如果是提取要求或問題,請在 AB#ID [標題] 或 [描述] 中輸入, (不是批註) 。Or, for a pull request or issue, enter the AB#ID within the title or description (not a comment).

從 GitHub 認可或提取要求中,使用下列語法來建立 Azure Boards 工作專案的連結。From a GitHub commit or pull request, use the following syntax to create a link to your Azure Boards work item. AB#ID 認可訊息或提取要求的文字內輸入,在 AB#ID 提取要求標題或描述內輸入, (不是提取要求批註) 。Enter the AB#ID within the text of a commit message or for a pull request, enter the AB#ID within the pull request title or description (not a pull request comment).

AB#{ID}

例如, AB#125 會連結至工作專案識別碼125。For example, AB#125 will link to work item ID 125.

此外,您可以輸入認可或提取要求訊息來轉換工作專案。In addition, you can enter a commit or pull request message to transition the work item. 系統會辨識 fix, fixes, fixed 並將它套用至接下來的 # 提及專案。The system will recognize fix, fixes, fixed and apply it to the #-mention item that follows. 如所示,會提供一些範例。Some examples are provided as shown.

範例:Examples:

認可訊息Commit message 動作Action
Fixed AB#123 連結工作專案並將其轉換成「已完成」狀態。Links and transitions the work item to the "done" state.
Adds a new feature, fixes AB#123. 連結工作專案並將其轉換成「已完成」狀態。Links and transitions the work item to the "done" state.
Fixes AB#123, AB#124, and AB#126 Azure Boards 工作專案123、124和126的連結。Links to Azure Boards work items 123, 124, and 126. 只會將第一個專案(123)轉換成「已完成」狀態。Transitions only the first item, 123 to the "done" state.
Fixes AB#123, Fixes AB#124, Fixes AB#125 Azure Boards 工作專案123、124和126的連結。Links to Azure Boards work items 123, 124, and 126. 將所有專案轉換成「已完成」狀態。Transitions all items to the "done" state.
Fixing multiple bugs: issue #123 and user story AB#234 GitHub 問題123與 Azure Boards 工作專案234的連結。Links to GitHub issue 123 and Azure Boards work item 234. 沒有任何轉換。No transitions.

注意

如果您已將相同的 GitHub 存放庫連線到兩個或多個 Azure DevOps 組織中定義的專案,您可能會看到非預期的 AB # 提及連結。If you have connected the same GitHub repo to projects defined in two or more Azure DevOps organizations, you may see unexpected AB# mention linking. 如需詳細資訊,請參閱 疑難排解 GitHub & Azure Boards 整合For details, see Troubleshoot GitHub & Azure Boards integration. 基於這個理由,建議您只將 GitHub 存放庫連線到單一 Azure DevOps 組織中定義的專案。For this reason, we recommend that you only connect a GitHub repo to projects defined in a single Azure DevOps organization.

注意

連結至 GitHub 問題需要 Azure DevOps Server 2019 Update 1 或更新版本。Linking to a GitHub issue requires Azure DevOps Server 2019 Update 1 or later version.

  1. 若要連結至認可或提取要求,請開啟工作專案,然後選擇 [開發] 區段底下的 [ 加入連結 ]。To link to a commit or pull request, open the work item and choose Add Link under the Development section.

    開發區段,新增連結Development section, Add link

    若要連結到問題,請選擇 [ 連結 ] 索引標籤,然後選擇 [ 加入連結>現有專案]。To link to an issue, choose the Links tab, and then choose Add Link>Existing item.

    連結索引標籤,新增問題的連結Links tab, Add link to issue

  2. 從 [新增連結] 對話方塊中,選取其中一個 GitHub 連結類型、輸入認可、提取要求或問題的 URL,然後選擇 [確定]From the Add link dialog, select one of the GitHub link types, enter the URL to the commit, pull request, or issue and then choose OK.

    在這裡,我們會新增 GitHub 提取要求的連結。Here, we add a link to a GitHub pull request.

    GitHub 提取要求連結對話方塊GitHub pull request link dialog

    Azure Boards 會執行檢查,以確保您已輸入有效的連結。Azure Boards performs a check to ensure that you've entered a valid link. 連結至 GitHub 存放庫 必須與專案整合 ,否則驗證將會失敗。The linked-to GitHub repository must be integrated with the project or the validation will fail.

    在這裡,我們會新增 GitHub 問題的連結。Here, we add a link to a GitHub issue.

    新增連結對話方塊,GitHub 問題Add link dialog, GitHub issue

工作專案表單中的 [開發] 區段會列出使用 github 圖示建立給 GitHub 認可和提取要求的連結

開發區段會顯示 GitHub 連結Development section shows GitHub links

選擇提供的連結,以在 GitHub 中開啟認可或提取要求。Choose the link provided to open the commit or pull request in GitHub.

查看查看板上的 GitHub 物件View GitHub objects on Kanban board

在儀表板面板上啟用 GitHub 注釋之後,您可以快速開啟連結的 GitHub 認可、提取要求或問題,以取得更多詳細資料。With GitHub annotations enabled on the Kanban board, you can quickly open linked GitHub commits, pull requests, or issues for more detail.

看板面板會顯示 GitHub 連結Kanban board shows GitHub links

注意

GitHub 附注需要 Azure DevOps Server 2019 Update 1 或更新版本。GitHub annotations requires Azure DevOps Server 2019 Update 1 or later version.

如需啟用注釋的詳細資訊,請參閱 自訂卡片For details on enabling annotations, see Customize cards.

接下來嘗試這個Try this next