Defect #38814
openUnable to read Target Version of a Redmine issue using python-redmine module.
0%
Description
I am writing a python script using python-redmine module to automate notifying team about the list of Redmine issues in Design status but Target Version is not yet set in Redmine.
With the help of python-redmine documentation, it was quite easy to read issues and get the issue.status attribute.
Now, for a given issue, I would like to get the Target Version. I am able to list out the supported attributes of a Redmine issue and came to know that Target Version is internally referred as "fixed_version" in Redmine as per the output of
list(redmine.issue.get(1))
I tried to read it via different methods given below.
issue.fixed_version
issue.fixed_version.id
issue.fixed_version_id
But all the above options resulted in
raise exceptions.ResourceAttrError redminelib.exceptions.ResourceAttrError: Resource doesn't have the requested attribute
So tried the below lines, but it is always returning target_version_set
to true.
Can anyone please help me to get the Target Version of a Redmine issue?
My Redmine version is 4.1.0.stable.142, python version is 3.9.5 and python-redmine module version is 2.4.0
redmine = Redmine('http://redmine_url', username='uname', password='pwd')
issues = redmine.issue.filter(project_id=project_id, status_id='open', include='journals', sort='tracker,priority')
for issue in issues:
#target_version = None
#target_version = issue.fixed_version
#target_version = issue.fixed_version.id
#target_version = issue.fixed_version_id
issue_details = list(redmine.issue.get(issue.id))
print (issue_details)
target_version_set = getattr(issue_details,'fixed_version',True)
print (target_version_set)
#if issue.status == "Design" and target_version is None
if issue.status == "Design" and not target_version_set:
print(f"Target Version is not set for Issue No.", {issue.id})