python - 使用 WIQL 从 Azure Devops 检索链接的工作项

标签 python python-3.x azure-devops wiql

我一直在研究使用 azure-devops python 包从 Azure Devops 检索工作项,并在以下位置提供的示例代码的帮助下设法提取工作项:

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

但是,我正在尝试改进流程以获取特定工作项以及任何链接的“相关工作”项。 For instance, grabbing the parent, as well as "Test Feature"

我该怎么做?


编辑:

我已经接近于构建此功能,但是我的查询一直返回每个工作项,而不仅仅是链接的项。我的目标是从树的根工作项中检索所有子项。

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)
        """
)

最佳答案

我找到了我的问题的解决方案,从 MODE 中删除“ReturnMatchingChildren”,从而消除了额外的返回。此解决方案假定项目 ID 为 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)
        """
)

关于python - 使用 WIQL 从 Azure Devops 检索链接的工作项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62537655/

相关文章:

Python - 从带有链接的网页下载 CSV 文件

Azure 管道提取任务 7zip

azure - 无法在独立区域路径之间移动Azure DevOps

具有动态模型的 Azure ML 静态端点

python - REST 服务 Google Analytics 集成

python - 在 Windows 7 中为 Python 安装 selenium

python - Python HTTP始终使用套接字301

regex - 如何使用正则表达式仅匹配每行字符串的第一次出现

python - tensorflow 展平方法之间的区别

python-3.x - 如何在 tensorflow 中使用经过训练的简单前馈神经网络来预测新数据