Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Comments from All Projects with API using Python

Deleted user September 16, 2020

Hello,

So I have the following code below, but: I don't know how to get the comments from issues. Also, I'm confused about how to iterate between all the projects to grab all the issues. Right now, it's set up so that it can only get the information from a single project.

 

from jira import JIRA

import csv
user = "accountemail@address.com"

apikey = "apikeygoeshere"

server = "https://jirajirajira.atlassian.net"
options = {    "server": server}
jira = JIRA(options, basic_auth=(user,apikey))

size = 100

count = 0

while True:    start= count * size    

issues = jira.search_issues("project=PROJECTKEYGOESHERE", start,size)
    if len(issues) == 0:        

           break    

count += 1        
for issue in issues:        

print("ticket-no=", issue)         

print("IssueType=", issue.fields.issuetype.name)        

print("Status", issue.fields.status.name)        

print("Summary=", issue.fields.summary)        

print ("Comment:", issue.fields.comment.comments[0].author.name)    

  

1 answer

1 vote
DPKJ
Community Champion
September 18, 2020

@[deleted] Look like your pretty near to solving this issue, here are some suggestions against questions you have asked,

  • To gell all issues in Jira without limiting them with project boundary, try JQL in `jira.search_issues` without project, you can simply put some order by clause in this.
  • Now you will get all issues, you can easily iterate over them using for loop.
  • Also use 'comments = jira.comments(issue)` instead of 'comments = issue.fields.comment.comments', later doesn't seems to work sometimes.

I hope this helps.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events