Hi All,
Jira + Python : Could you please help me to retrieve the last comment of an issue?
for Issue in jira.search_issues('project=YKP and assignee='+ Assignee +
' and status not in ("Discarded") and updated > -7d ORDER BY issuekey, issuetype, status'):
#for SubIssue in jira.search_issues('project=YKP and "epic link"= ' + Issue.key +' and assignee='+ Assignee + ' and status not in ("Discarded") and updated > -7d ORDER BY issuekey, issuetype, status'):
print(">>>" + '{} | {} | {} | {}'.format(Issue.key, Issue.fields.issuetype, Issue.fields.status, Issue.fields.summary))
Thanks in Advance,
Maadi
Hello,
You can try this, it will return all comment of the issue with created date and updated date
https://yourdomain/rest/api/2/issue/{issueKey]/comment
Hope this helps
Regards
Thanks for the reply @Mohamed Benziane.
I am using JIRA library in Python and I am looking for the last comment entered for an issue.
Let me know do you have any suggestion?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Sunesh M S,
Can you try this
comments_a = issue.fields.comment.comments comments_b = jira.comments(issue) # comments_b == comments_a
I don't know if it will return you the comment date but you can test and let me know
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried like below,
print(issue.fields.comment.comments)
print(jira.comment(IssueNo,'12252').body)
Output
[<JIRA Comment: id='12252'>]
completed. unit testing done.
------
For another issue I got the below output, here this issue have multiple comments,
[<JIRA Comment: id='10920'>, <JIRA Comment: id='12321'>, <JIRA Comment: id='1402
2'>, <JIRA Comment: id='14053'>, <JIRA Comment: id='14083'>]
Let me know do you have any suggestion to get the MAX id from the above list.
[I tried MAX(listname), but not worked.]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sunesh M S
I'm not expert but i tried this and it worked :
comment=jira.comments('issueKey')
a=int(0)
for i in comment:
if int(i.id)>a:
a=int(i.id)
If it works for you you can go for a loop to get all last comment of your jira search.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mohamed Benziane, I am travelling today, So I can check this on next week only. Thanks for your comments. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mohamed Benziane Thanks for you support. :)
comment=jira.comments(IssueNo)
a=int(0)
for i in comment:
if int(i.id)>a:
a=int(i.id)
print(jira.comment(IssueNo,a).body)
The above code will print the last comment (Text).
[Solved]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sunesh M S
Glad i helped you. Feel free to accept my answer to help other people with same issue.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Can you help in getting only the "External Comments"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @[deleted]
What do you meant by "External comments" ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it's about get the "internal" parameter to know if the comment is for the user or just for the internal people. I've got the same issue. How can we get the "is_internal" parameter from the comments?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Take a look at this doc
You have a parameter for internal comment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, I saw that, but I need to get that parameter with Python. Do you know how? Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you will need to use the requests module in python.
here the url to use in you code : https://yourdomain/rest/servicedeskapi/request/{issueIdOrKey}/comment?public=false
you will have only the internal ticket thank to the public parameter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This will give you last comment, author name, time when its updated.
from jira import JIRA
jira = JIRA(auth=(uname, pwd), options={'server': 'https://jira.company.com/'})
output = {}
for result in jira.search_issues(your query, startAt=0, maxResults=100):
issue = jira.issue(result.key)
for com in issue.fields.comment.comments:
comment = com.body
author = com.author.displayName
time = com.created
output['Jira No'] = issue
output['Comment'] = comment
output['author'] = author
output['Time'] = time
print(output)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.