在VSTS示例的Github存储库中发布了一条消息(即导致请求请求的问题)之后,我得到了解决问题的提示。
解决方案是使用:
- 一个带有
Wiql
类的wiql查询对象 query_by_wiql
功能- 将查询结果(具有WorkItem ID的引用)转换为具有
get_work_item
功能的WorkItem (或get_work_items
通过一次处理处理多个WorkItem)
这是我对这个问题的解决方案:
[针对版本5.1和azure-devops模块进行了更新,以取代VSTS]
from azure.devops.connection import Connectionfrom msrest.authentication import BasicAuthenticationfrom azure.devops.v5_1.work_item_tracking.models import Wiqltoken = "hcykwckuhe6vbnigsjs7r3ai2jefsdlkfjslkfj5mxizbtfu6k53j4ia"team_instance = "https://tfstest.toto.com:8443/tfs/Development/"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)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)