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

标签 python azure azure-devops azure-devops-rest-api

我正在尝试连接到 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/

相关文章:

python - AWS python Lambda 无法访问 EFS 文件

python - Tensorboard 中重复的所有变量是什么?

json - 删除/替换 Azure 逻辑应用中解析的 JSON 输出中的字符

git - 致命: Could not read password for 'https://OrganizationName@dev.azure.com' : terminal prompts disabled

sql-server - VSTS : Deploy Azure SQL DACPAC throws an error

python - 是否可以在 Mac、linux 和 Windows 中将 python3 应用程序部署为自执行文件?如何?

python - flask 同一页面上的多个表单

python - Azure Functions : Exception while executing function: Functions. x <--- 结果:失败异常:ModuleNotFoundError:没有名为 '_cffi_backend' 的模块

wpf - 启用侧面加载后,为什么 MSIX 不会在每次应用程序运行时自动检查更新?

typescript - Angular2 在 Visual Studio Team Services 中构建(原为 Visual Studio Online)