JIRA-Python: How can I pass user inputs in Jira issue search?

Lakshveer Singh July 19, 2017

I'm trying to get information based on the input provided by user and then passing it in a function which gives back the issues created. But I'm not able to pass the objects in search_issue query?

def issuecreated(projectname, reportername, datefrom, dateto):
print projectname, reportername, datefrom, dateto
for i in jira.search_issues('project = projectname AND reporter = reportername AND created > datefrom and created < dateto'):
return i

projectname=raw_input("Please give the project name: ")
reportername=raw_input("Please provide the name of creator: ")
datefrom=raw_input("Please provide the time interval for which you want issues: From ")
dateto=raw_input("Please provide the time interval for which you want issues: To ")
print projectname, reportername, datefrom, dateto
issuecreated(projectname, reportername, datefrom, dateto)

 

I'm able to see the inputs in the function by it is not getting passed in jira.search_issues.

Please help.

Thanks!

1 answer

0 votes
MattS
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 19, 2017

Create a string that is made up of the JQL you know and the input from users. Then pass that string to jira.search_issues()

"Static text %s" % variablename

 

Lakshveer Singh July 19, 2017

Thanks for the input!

I tried to pass the string into jira.search_issues(), but it throws error, jira.exceptions.JIRAError on jira.search_issue() line. Here is what I did.

query = 'project = projectname AND reporter = reportername AND created > datefrom and created < dateto'

for i in jira.search_issues(query):
print i

 

I have given the encoding magic comments to convert Unicode.

Lakshveer Singh July 23, 2017

It works now, thanks!

Anto Praveen January 21, 2019

How it worked , i am facing the same issue.

Anto Praveen January 21, 2019

worked now :)

rithwik_poleneni March 6, 2020

@Lakshveer Singh @Anto Praveen Can you help me I am facing similar problem 
here is my line : issues_in_project = jira.search_issues('status = "Pending QA Deployment" AND projectname = ALPHA', startAt=0, maxResults=2000, validate_query=True, fields=None, expand=None, json_result=None)

 

I want to pass projectname as parameter. I am seeing issue while running code 

papiha August 20, 2021

hi @Lakshveer Singh 

can you hep me out. I am also looking for parameter to project. when i hard coded the project name as < project in (x,y,z) > it work. now i want to give this X,Y,Z project in excell and in query i want to read from excel.

Suggest an answer

Log in or Sign up to answer