如何使用 python 访问 Azure Dev Ops 数据,例如日期之间的变更集?
How to access azure Dev Ops data such as Changeset between dates using python?
我正在尝试连接到 AZURE Dev-Ops 并获取更改集信息以使用 PYTHON 自动准备发行说明。
阅读 github link 中提供的文档和过程后,我使用了以下内容:
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint
# Fill in with your personal access token and org URL
personal_access_token = 'mypattokenvalue'
organization_url = 'https://dev.azure.com/myorg'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
tfsv_client = connection.clients.get_tfvc_client()
project_name="myprojname"
search_criteria=".item_path='$/myprojname/Trunk/Main',.fromDate:'01-01-2019',.toDate:'11-13-2019-2:00PM'"
changeset_info = tfvcclient.get_changesets(project=project_name,search_criteria=search_criteria)
执行代码时抛出错误:
'str' object has no attribute 'item_path' in following line of code of the package eventhoughi provided Item_path value:
255 if search_criteria is not None:
--> 256 if search_criteria.item_path is not None:
257 query_parameters['searchCriteria.itemPath'] = search_criteria.item_path
我曾尝试以字典的形式给出搜索条件,但也给出了同样的错误。如果根本不提供项目路径,则会引发相同的错误。
因此我不确定如何将数据提供到 get_changesets 方法的搜索条件参数中。
我向任何人请求有关如何提供数据的帮助,以便我可以使用 PYTHON?[=14 从 AZURE Dev Ops 的给定项目的主分支下使用日期范围查询变更集的信息=]
向现有 post 添加更多查询- 2019 年 11 月 15 日更新:
这是包中的 defect/bug 吗,因为它没有采用我尝试提供的值,或者我提供搜索条件的方式有误?
如果这是一个合法的问题,你能告诉我在哪里可以记录缺陷吗?
如果提供的值或我提供值的方式有误,你能show/explain给我正确的方法吗?
提前致谢
此致
柴塔雅
如错误提示str' object has no attribute 'item_path'
。您定义的变量search_criteria是str
类型。您无法获取 str search_criteria 不存在的属性 item_path
。
你应该定义一个对象类型 search_criteria 请检查下面的代码作为例子。
search_criteria = type('',(object,),{"item_path":'$/myprojname/Trunk/Main',"fromDate":'01-01-2019', "toDate":'11-13-2019-2:00PM'})
我正在尝试连接到 AZURE Dev-Ops 并获取更改集信息以使用 PYTHON 自动准备发行说明。
阅读 github link 中提供的文档和过程后,我使用了以下内容:
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint
# Fill in with your personal access token and org URL
personal_access_token = 'mypattokenvalue'
organization_url = 'https://dev.azure.com/myorg'
# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
tfsv_client = connection.clients.get_tfvc_client()
project_name="myprojname"
search_criteria=".item_path='$/myprojname/Trunk/Main',.fromDate:'01-01-2019',.toDate:'11-13-2019-2:00PM'"
changeset_info = tfvcclient.get_changesets(project=project_name,search_criteria=search_criteria)
执行代码时抛出错误:
'str' object has no attribute 'item_path' in following line of code of the package eventhoughi provided Item_path value:
255 if search_criteria is not None:
--> 256 if search_criteria.item_path is not None:
257 query_parameters['searchCriteria.itemPath'] = search_criteria.item_path
我曾尝试以字典的形式给出搜索条件,但也给出了同样的错误。如果根本不提供项目路径,则会引发相同的错误。
因此我不确定如何将数据提供到 get_changesets 方法的搜索条件参数中。
我向任何人请求有关如何提供数据的帮助,以便我可以使用 PYTHON?[=14 从 AZURE Dev Ops 的给定项目的主分支下使用日期范围查询变更集的信息=]
向现有 post 添加更多查询- 2019 年 11 月 15 日更新:
这是包中的 defect/bug 吗,因为它没有采用我尝试提供的值,或者我提供搜索条件的方式有误? 如果这是一个合法的问题,你能告诉我在哪里可以记录缺陷吗? 如果提供的值或我提供值的方式有误,你能show/explain给我正确的方法吗?
提前致谢
此致
柴塔雅
如错误提示str' object has no attribute 'item_path'
。您定义的变量search_criteria是str
类型。您无法获取 str search_criteria 不存在的属性 item_path
。
你应该定义一个对象类型 search_criteria 请检查下面的代码作为例子。
search_criteria = type('',(object,),{"item_path":'$/myprojname/Trunk/Main',"fromDate":'01-01-2019', "toDate":'11-13-2019-2:00PM'})