如何使用python访问诸如日期之间的Changeset之类的Azure Dev Ops数据? [英] How to access azure Dev Ops data such as Changeset between dates using python?

查看:50
本文介绍了如何使用python访问诸如日期之间的Changeset之类的Azure Dev Ops数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to connect to AZURE Dev-Ops and acquire change set information to automate the release notes preparation using PYTHON.

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

Upon reading the documentation and the process provided in from github link, i have used the following:

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)

执行代码后会引发错误:

Upon executing the code it threw the error:

'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

我试图以字典的形式给出搜索条件,这也给出了相同的错误.如果根本不给出Item路径,则会引发相同的错误.

I have tried to give the search criteria in form of dictionary also that also gave the same error. If do not give Item path at all it throws the same error.

因此,我不确定如何将数据提供给get_changesets方法的搜索条件参数.

Hence i am not sure how to provide the data into the search criteria parameter to the get_changesets method.

我要求任何人提供有关如何提供数据的帮助,以便我可以使用PYTHON在AZURE Dev Ops中使用给定项目的主分支下的日期范围来查询变更集的信息?

I request help from any one on how to provide the data so that i can query the information of changeset using date range under main branch of a given project from AZURE Dev Ops using PYTHON?

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

这是否是包装中的缺陷/错误,因为它没有采用我尝试提供的值,或者我提供的搜索标准错误?如果这是合法问题,请您告诉我该在哪里记录缺陷?如果提供的值或我提供的值的方法有误,您可以显示/解释正确的方法吗?

Is this a defect/bug in the package as it is not taking the values however i try to provide or the way i provided the search criteria is wrong? If this is a legitimate issue,can you please let me know where can i log a defect against it? If the values provided or the way i have provided the values are wrong can you please show/explain me the correct way?

预先感谢

致谢

ChaitayaNG

ChaitayaNG

推荐答案

由于错误表明 str'对象没有属性'item_path'.您定义的变量 search_criteria str 类型.您无法获取str search_criteria不存在的属性 item_path .

As the error indicates that str' object has no attribute 'item_path'. The variable search_criteria you defined is a str type. You cannot get the attribute item_path which does not exist for str search_criteria.

您应该定义一个search_criteria对象类型.例如,请检查以下代码.

You should define an object type of search_criteria Please check below code for example.

  search_criteria = type('',(object,),{"item_path":'$/myprojname/Trunk/Main',"fromDate":'01-01-2019', "toDate":'11-13-2019-2:00PM'})

这篇关于如何使用python访问诸如日期之间的Changeset之类的Azure Dev Ops数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆