[英]Azure DevOps Powershell get work item related to build pipeline
I have a build pipeline with a trigger on new branch creation.我有一个带有新分支创建触发器的构建管道。 The trigger works fine with me creating a new branch and linking a workitem task to the new branch.
触发器适用于我创建新分支并将工作项任务链接到新分支。
I have tried to run the query through the API to retrieve the workitem associated to the build but it always comes back blank.我试图通过 API 运行查询以检索与构建关联的工作项,但它总是返回空白。 I can retrieve the list of workitems in the project no problem.
我可以检索项目中的工作项列表没问题。
The URI I am using is:我使用的 URI 是:
https://dev.azure.com/{instance}/{project}/_apis/build/builds/{build id}/workitems?api-version=6.0 https://dev.azure.com/{instance}/{project}/_apis/build/builds/{build id}/workitems?api-version=6.0
This returns a blank value.这将返回一个空白值。 If I remove the "workitems" then I get a list of all the builds with one of the entries matching the build id.
如果我删除“工作项”,那么我会得到所有构建的列表,其中一个条目与构建 ID 匹配。 The PAT I am using has full access to the project (currently testing so have not been specific for the access).
我正在使用的 PAT 可以完全访问该项目(目前正在测试,因此尚未具体访问该访问权限)。
This is the last step for me to complete and I can piece the whole puzzle.这是我完成的最后一步,我可以拼凑整个拼图。
UPDATE1: 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. UPDATE1:我现在注意到在管道日志中没有相关的工作项,即使我从工作项中创建了分支。
UPDATE2: I notice if I do a commit and associated the work item then the build lists the related work item. UPDATE2:我注意到如果我进行提交并关联工作项,那么构建会列出相关的工作项。 Does not appear to work when creating a new branch, only comitting to that new branch
创建新分支时似乎不起作用,仅提交到该新分支
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.在工作项中创建新分支时,需要在 Build Pipeline 中更改构建分支。
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.当您运行 Rest API: Builds - Get Build Work Items Refs时,它将显示相关的工作项。
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/workitems?api-version=6.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.