Get all requirements path for all issues returned by a jql
The following script will get all requirements path for all issues returned by a jql.
In this example, all issues under the project 'REQ' will be returned with their path.
Function
def get_requirements_path_for_issues(host_url, username, password, jql):
"""
This method is used to get all requirements path for all issues returned by a jql
Template parameters:
[jql] the JQL statement
"""
# The REST API path to search for tree elements
path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/issue/req-path/' + jql
# Send a GET request to get all requirements path for all issues returned by a jql
# Return the result of the GET
try:
return requests.get(host_url + path_uri, auth=HTTPBasicAuth(username, password))
except requests.exceptions.RequestException as e:
print e
Main
# ['project = REQ'] jql parameter to get the parent issue keys
response = get_requirements_path_for_issues(HOST_URL, USERNAME, PASSWORD, 'project = REQ')
# Check response if requirements path are found
if response.status_code == 200:
# Get the value of the JSON response and print in a readable JSON format
# json dumps formats the JSON string in readable format
json_object = json.loads(response.text)
print json.dumps(json_object, indent=4)
else:
print 'Error code: ', response.status_code
print response.text
Refer to Constant variable for information of the following constant variable: [HOST_URL, USERNAME, PASSWORD]