简体   繁体   中英

Retrieving linked Work Items from Azure Devops, using WIQL

I have been looking into retrieving Work Items from Azure Devops with the azure-devops python package, and have managed to pull down work items with help from the sample code provided at:

https://github.com/microsoft/azure-devops-python-samples/blob/main/src/samples/work_item_tracking.py

However, I am trying to refine the process to grab a specific work item along with any linked 'related work' items. For instance, grabbing the parent, as well as "Test Feature"

How would I go about doing this?


Edit:

I've gotten closer to building this feature, however my query keeps returning every work item rather than just the linked items. My Goal is to retrieve all child items from the root work item of the tree.

wiql = Wiql(
   query="""
            SELECT * FROM workitemLinks 
            WHERE (Source.[System.AreaPath] Under 'devOpsTesting\\testArea')
            AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward')
            AND (Source.[System.Id] = 3)  
            ORDER BY [System.Id]
            MODE (Recursive, ReturnMatchingChildren)
        """
)

I found the solution to my problem, removing 'ReturnMatchingChildren' from MODE got rid of the extra returns. This solution assumes an item id of 3.

wiql = Wiql(
   query="""
            SELECT * FROM workitemLinks 
            WHERE (Source.[System.AreaPath] Under 'devOpsTesting\\testArea')
            AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward')
            AND (Source.[System.Id] = 3)  
            ORDER BY [System.Id]
            MODE (Recursive)
        """
)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM