【问题标题】:Azure Dev/Ops - Ingestion of Analytics View data using PythonAzure Dev/Ops - 使用 Python 引入分析视图数据
【发布时间】:2020-02-03 13:41:02
【问题描述】:

我想从 Azure DevOps 访问分析视图数据以访问已注册的项目活动。

有没有人可以举例说明他们如何使用 azure-devops python 库来做到这一点?

我没有找到涉及从分析视图中提取数据的示例。基本上,我需要一个 Python 脚本来显示我的项目的所有分析视图字段。

【问题讨论】:

  • 您的意思是先从 azure devops 摄取数据,然后将这些数据流式传输到 azure databricks?
  • @MerlinLiang-MSFT 完全正确

标签: python python-3.x azure azure-devops azure-devops-rest-api


【解决方案1】:

经过一番研究,我设法部分解决了我的问题,因为这个解决方案并没有从分析视图中获取所有内容,此外查询结果中有 20k 条记录的限制:

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.devops.v5_1.work_item_tracking.models import Wiql


token = 'xxx'
team_instance = 'https://dev.azure.com/xxx'


credentials = BasicAuthentication("", token)
connection = Connection(base_url=team_instance, creds=credentials)


def print_work_items(work_items):
    for work_item in work_items:
        print(
            "{0} {1}: {2}".format(
                work_item.fields["System.WorkItemType"],
                work_item.id,
                work_item.fields["System.Title"],
            )
        )


wit_client = connection.clients.get_work_item_tracking_client()


def get_TC_from_query(query):
    query_wiql = Wiql(query=query)
    results = wit_client.query_by_wiql(query_wiql).work_items
    # WIQL query gives a WorkItemReference => we get the corresponding WorkItem from id
    work_items = (wit_client.get_work_item(int(result.id)) for result in results)
    print_work_items(work_items)

get_TC_from_query(
    """\
SELECT
        [System.Id],
        [System.WorkItemType],
        [System.Title],
        [System.State],
        [System.AreaPath],
        [System.IterationPath]
FROM workitems
WHERE
        [System.TeamProject] = 'Project'
        and [System.WorkItemType] = 'Product Backlog Item'
        and [System.State] = 'Done'
ORDER BY [System.ChangedDate] DESC
"""
)    

【讨论】:

    猜你喜欢
    • 2020-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 2021-03-24
    • 2019-12-19
    相关资源
    最近更新 更多