Azure DevOps Powershell 獲取與構建管道相關的工作項 (Azure DevOps Powershell get work item related to build pipeline)


問題描述

Azure DevOps Powershell 獲取與構建管道相關的工作項 (Azure DevOps Powershell get work item related to build pipeline)

我有一個構建管道,其中包含創建新分支的觸發器。觸發器適用於我創建新分支並將工作項任務鏈接到新分支。

我嘗試通過 API 運行查詢以檢索與構建關聯的工作項,但它總是返回空白的。我可以檢索項目中的工作項列表沒有問題。

我使用的URI是:

https://dev.azure.com/{instance}/{project}/_apis/build/builds/{ build id}/workitems?api‑version=6.0

這會返回一個空白值。如果我刪除“工作項”;然後我得到所有構建的列表,其中一個條目與構建 ID 匹配。我正在使用的 PAT 可以完全訪問該項目(目前正在測試,因此尚未具體訪問)。

這是我要完成的最後一步,我可以拼湊整個難題。

這是我要完成的最後一步。

p>

UPDATE1:我現在註意到管道日誌中沒有相關的工作項,即使我從工作項中創建了分支。

構建日誌截圖

UPDATE2:我注意到如果我提交並關聯了工作項,那麼構建會列出相關的工作項。


參考解法

方法 1:

Build pipeline adds related work items by reading the work items associated with the checkout commit.

I have now noticed that in the pipeline log there is no related work item even though I create the branch from within the work item.

When you create the new branch in work item, you need to change the build branch in Build Pipeline.

enter image description here

Then the build will use the newly created branch to build pipeline, the work items will relate to the Build.

When you run the Rest API: Builds ‑ Get Build Work Items Refs, it will show the related work item.

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/workitems?api‑version=6.0

enter image description here

(by ShaneKevin Lu‑MSFT)

參考文件

  1. Azure DevOps Powershell get work item related to build pipeline (CC BY‑SA 2.5/3.0/4.0)

#powershell #azure-devops #azure-devops-pipelines #workitem #azure-pipelines






相關問題

玩弄 C# 加密 (Playing around with C# encryption)

查找具有特定 startname 的特定服務 (Finding specific services with specific startname)

試圖從事件日誌中獲取數據到電子郵件中的 html (Trying to get data from event logs into html in email)

如何通過powershell獲取請求的authtoken (How to obtain authtoken for request via powershell)

如何在錯誤時繼續使用 &$var 調用可執行文件 (How to continue on error a call to an executable using &$var)

在同一範圍內從 c# 調用多個 powershell 命令 (Invoke multiple powershell commands from c# on the same scope)

如何在 Powershell 二進制模塊(.Net Standard 和 Nuget)中處理公共和私有依賴項和打包 (How to handle public and private dependencies and packaging in Powershell binary module (.Net Standard & Nuget))

如何使用參數(描述空白)獲取廣告中的所有 OU - 沒有描述? (How to get all OU in Ad with parameter (description blank ) - without description?)

遠程服務器返回錯誤:(400) 錯誤請求。在 C:\Program Files\WindowsPowerShell\Modules\CosmosDB\3.1.0.293\CosmosDB.psm1 (The remote server returned an error: (400) Bad Request. At C:\Program Files\WindowsPowerShell\Modules\CosmosDB\3.1.0.293\CosmosDB.psm1)

Powershell 檢查文件類型 (Powershell check file type)

服務器待重啟 (Server Pending Reboot)

PowerShell 的 Invoke-WebRequest 在 Docker 容器中不起作用 (PowerShell's Invoke-WebRequest not working within a Docker Container)







留言討論