Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate comment documentation is up to date. #358

Closed
mramanathan opened this issue Mar 5, 2017 · 9 comments
Closed

Validate comment documentation is up to date. #358

mramanathan opened this issue Mar 5, 2017 · 9 comments

Comments

@mramanathan
Copy link

After successfully completing basic authentication, I setup a jira object to the production server.

On the jira object, while trying to extract the comment text using the id of that comment, instead of text, command returns the comment id.

Referred to the docs for the usage, it looks to be ok.

Tried this from jirashell.

In [70]: cmnt = jira.comment('SREC-255', '2590283')
In [71]: print cmnt1
Out[71]: <JIRA Comment: id=u'2590283'>

What's wrong with the usage here ?

@suresh753
Copy link

suresh753 commented Apr 13, 2017

I do not know but you can get comments

issue = jira.issue(SREC-255) 
issue.raw['fields']['comment']['comments']

@fender4645
Copy link

@mramanathan I know this is old but for historical sake, the "comment()" method returns a Comment object. If you want the text, you need to get the "body" property:

cmnt = jira.comment('SREC-255', '2590283')
print cmnt.body

@nojiratz
Copy link

nojiratz commented Dec 7, 2017

Genius! The cmt.body is exactly what I was looking for!

@hrm232
Copy link

hrm232 commented Feb 12, 2018

I tried above code it did not work, hence tried as follow way. I get error at last line of snippet.
Any idea what's missing?

jql='project = TMP AND key = TMP-281 ORDER BY createdDate ASC'
issues = jira.search_issues(jql, 0, 1000)
for issue in issues:
print(issue.fields.issuetype.name)
print(issue.fields.reporter.displayName)
print(issue.fields.comment.comments)

@fender4645
Copy link

@hrm232 what's the error you're getting with your code? issue.fields.comment.comments will return a list of comment objects (one object for each comment in the issue)...or an empty list if there aren't any comments in the issue.

@alexmgr
Copy link

alexmgr commented Feb 17, 2018

@fender4645 I'm hitting the same error as @hrm232 on 1.0.10 and 1.0.11. You essentially get an AttributeError:

import jira as jira_

jira = jira_.JIRA(url, basic_auth=(username, password))
issues = jira.search_issues(SOME_QUERY)
for issue in issues:
    # This works and returns comments as intended
    print([comment.body for comment in jira.comments(issue)])
    # Works fine
    print(issue.fields.summary, issue.fields.description)
    # This raises attribute error:
    # AttributeError: type object 'PropertyHolder' has no attribute 'comment'
    print(issue.fields.comment.comments)

Versions (I'm on 1.0.10 due to #501 ):

certifi==2018.1.18
chardet==3.0.4
defusedxml==0.5.0
idna==2.6
jira==1.0.10
oauthlib==2.0.6
pbr==3.1.1
requests==2.18.4
requests-oauthlib==0.8.0
requests-toolbelt==0.8.0
six==1.11.0
urllib3==1.22

@chalbersma
Copy link

chalbersma commented Jul 18, 2018

I'm getting the same error as @alexmgr with jira==1.0.15. Interestingly I don't see the error when using jirashell.

I did find a workaround. Using

yourjiraconnection.comments("ticketkey-111")

Yields an object that's similar to what should be in the object.

@hdost hdost added the docs label Oct 16, 2018
@hdost hdost changed the title Unable to extract comment text using Python v2.7 and Jira-Python 1.0.10 Validate comment documentation is up to date. Oct 16, 2018
@eschwaiger
Copy link

@hrm232 Same issue but I think I figured it out. When you do your jira.search_issue you have to specify fields to pull with it, in this case your comments fields. Try this:

jql='project = TMP AND key = TMP-281 ORDER BY createdDate ASC'
issues = jira.search_issues(jql, 0, 1000, fields='comments')
for issue in issues:
print(issue.fields.issuetype.name)
print(issue.fields.reporter.displayName)
print(issue.fields.comment.comments)

No more errors, hope this helps.

@stale
Copy link

stale bot commented Oct 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 15, 2019
@stale stale bot closed this as completed Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants