Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,366,371
Community Members
 
Community Events
168
Community Groups

Hi to fetch comment from jira ticket using python code?

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

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
DPK J Community Leader Sep 09, 2019

You need to do something like this,

comments =  issue.fields.comment.comments

for comment in comments:
    print("Text: ", comment.body)

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

1 vote
Answer accepted

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.

DPK J Community Leader Sep 08, 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
DPK J Community Leader Sep 08, 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
DPK J Community Leader Sep 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