How to pass variable in jql while using jira search api in python

Deleted user January 5, 2020

Hello Team, 

 

I am using below search API to fetch jira issues:

 

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-search-get

 

let say value of the project and labels are variable then how can i pass in below jql query ?

 

project_name = 'DEVOPS'

label_name = 'alert_manager'

query = {
'jql': 'project = DEVOPS and labels = alert_manager and summary ~ "TargetResponseTime_5_Sec_For_2min" and status not in (Closed, Done)'
}

 

i want to pass project_name and label_name variable in above jql. how to pass ?

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Deleted user January 5, 2020

String interpolation is what i was looking for. 

 

query = {
'jql': f'project = {project_name} and labels = {label} and summary ~ "TargetResponseTime_5_Sec_For_2min" and status not in (Closed, Done)'
}

 

Worked

 

thanks  

rithwik_poleneni March 6, 2020

@[deleted] - I have the following line here for JQL i want to pass two parameters how can I achieve it ?

issues_in_project = jira.search_issues('status = "Pending QA Deployment" AND project = ALPHA', startAt=0, maxResults=2000, validate_query=True, fields=None, expand=None, json_result=None)

two parameters are status and project. Please let me know how to achieve this ?

mini trivedi May 15, 2021

Hi @rithwik_poleneni 

 

This works for me.

status = "'Pending QA Deployment'"

project = "ALPHA"

issues_in_proj = jira.search_issues('project=%s and status =%s' % (project,status), startAt=0, maxResults=2000, validate_query=True, fields=None, expand=None, json_result=None)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events