Hi to fetch comment from jira ticket using python code?

Annapurna September 8, 2019

Hi,

For my automation work i have to fetch comment from JIRA ticket. Please let me know how to fetch comment from jira ticket.

3 answers

2 accepted

1 vote
Answer accepted
Annapurna September 9, 2019

Hi,

I am trying to fetch latest comment from JIRA ticket. 

i used this in python script.

issue.fields.comment 

<class 'jira.resources.PropertyHolder'>

this is the output i received.

Please let me know what is the issue
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 9, 2019

You need to do something like this,

comments =  issue.fields.comment.comments

for comment in comments:
    print("Text: ", comment.body)
Yasin Bhuiyan August 11, 2022

I used the above script. However, I am getting following Attribute Error: 'PropertyHolder' object has no attribute 'comment'

1 vote
Answer accepted
Annapurna September 8, 2019

Thank you..i am able to read the description.

Now when new ticket is arrived to my jira account i have to fetch description automatically. Am trying for that.

Can you help me.

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 8, 2019

@AnnapurnaI have already replied for this in your other question.

In external environment, you only have two possibilities, Polling Search API, or Webhooks.

 

Also, if my above answer helped you, please upvote and accept it, so that other people looking for same thing can also get help.

0 votes
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 8, 2019

You have two ways to do this,

  1. Using Jira Python (python wrapper for calling Jira API's)
    1. Reference - https://pypi.org/project/jira/
    2. Comments Example - https://jira.readthedocs.io/en/latest/examples.html#comments
  2. Using rest API's provided by Jira
    1. You will need to use 'requests' module from python (or any other) to simply consume Rest API provided by Jira
    2. API Reference - https://docs.atlassian.com/software/jira/docs/api/REST/8.2.2/
    3. Get comment based on issue - https://docs.atlassian.com/software/jira/docs/api/REST/8.2.2/#api/2/issue-getComments
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 10, 2019

Can you also mark this as accepted solution if someone is looking for comprehensive solution.

Like Preeti Chaturvedi likes this

Suggest an answer

Log in or Sign up to answer