Forums

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

How to add same comment in multiple defects in JIRA using Python script

pradeep br July 13, 2020

I'm trying to add a static comment into multiple defects at the same time. I was able to use jira.add_comment to add it into a single defect. But i'm not sure how it can be done for multiple defects at the same time. i tried reading the defect id's from the text file to add comments in multiple defects. But that didn't work. Please let me know how this can be done using Python script.

 

from jira import JIRA
options = {'server': 'https://jira.com'}
jira = JIRA(options, basic_auth=('username', 'pwd'))
f = open('C:////jiraccess//defect.txt')
line = f.readline()
while line:
comment = jira.add_comment(line, 'closed')
line = f.readline()
f.close()

 

1 answer

1 accepted

1 vote
Answer accepted
Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2020

readline() includes the newline character(s), which causes a problem when looking for that issue ID in the add_comment() method. Add a call to rstrip() to remove it/them; be sure to do so on both calls to readline().

f.readline().rstrip() 

pradeep br July 14, 2020

Thank you so much Payne for your help. That worked like a charm!!.

Like Payne likes this

Suggest an answer

Log in or Sign up to answer