I'm trying to set up my build pipeline in a way that, if it fails for some reason, then creates a new work item. However, is it possible to add a related work item for these automatically created work items?
Right now, I'm manually adding a related user story just to keep my azure board organized and clean, and I have a guess that this related work is also an additional field, but couldn't find which of these fields should I use and how to use them in the options tab.
This is the desired result that I'm looking for:
I found this question that have a similar problem that I have, just missing this step on how to add related work item.
is it possible to add a related work item for these automatically created work items?
I am afraid that the Create work item on failure option in Pipeline option doesn't support adding a related work item for newly created work items.
It only supports defining the field of work items. But the Parent work item link belongs to relations .
Since you don't want to use the Rest API, I suggest that you could use the Create Work Item task from Create Work Item extension.
Then you could directly add this task at the end of your agent job.
For example:
In this task, you could define the related work item:
Then you could set the condition in the task(eg Only when a previous task has failed).
In this case, when the pipeline fails, it will run task and create a work (contain parent work item link).
As of this time, however, adding parent work item directly for created work items in "Create work item on failure" is not currently supported, because the information about related work items is not stored in fields, but in relations.
As an alternative method, you can create a work item and set parent for it by REST API Work Items - Create .
POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/${type}?api-version=6.0
Here is an example:
[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "SampleTask"
},
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{parent work item id}"
}
}
]
The second paragraph is used to add parent.
Details on how to run the REST API in your pipeline can be found in your linked questions .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.