问题
I am trying to connect to AZURE Dev-Ops and acquire change set information to automate the release notes preparation using PYTHON.
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
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.
Hence i am not sure how to provide the data into the search criteria parameter to the get_changesets method.
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?
Adding additional queries to the existing post- update on Nov 15 2019:
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?
Thanks in Advance
Regards
ChaitayaNG
回答1:
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.
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'})
来源:https://stackoverflow.com/questions/58856596/how-to-access-azure-dev-ops-data-such-as-changeset-between-dates-using-python