gpt4 book ai didi

python - 如何使用 python 访问 Azure Dev Ops 数据,例如日期之间的变更集?

转载 作者:行者123 更新时间:2023-12-02 07:04:07 29 4
gpt4 key购买 nike

我正在尝试连接到 AZURE Dev-Ops 并获取更改集信息,以使用 PYTHON 自动准备发行说明。

阅读 github 中提供的文档和流程后链接,我使用了以下内容:

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 从 AZURE Dev Ops 的给定项目的主分支下使用日期范围查询变更集信息?

在 2019 年 11 月 15 日的现有更新后添加其他查询:

这是包中的缺陷/错误,因为它没有采用我尝试提供的值,或者我提供搜索条件的方式是错误的?如果这是一个合法问题,您能告诉我在哪里可以记录针对它的缺陷吗?如果提供的值或我提供值的方式错误,您能否向我展示/解释正确的方式?

提前致谢

问候

柴塔亚NG

最佳答案

由于错误表明str'对象没有属性'item_path'。您定义的变量 search_criteriastr 类型。您无法获取 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'})

关于python - 如何使用 python 访问 Azure Dev Ops 数据,例如日期之间的变更集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58856596/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com