DATA CENTER AND SERVER | CLOUD
Create Scheduled Adding of Issues
Oct 27, 2017
Contents
Create jobs for scheduled adding issues
The following script will create automatic issue import configurations.
In this example, the code will create a scheduled adding job for issues that contains the text "Login_UI_req" in summary field and store in the folder with the id 302.
Function def create_scheduled_job(host_url, username, password, project_key, job_name, folder_id, jql_or_filter, interval):
"""
This method allows the creation of jobs for the scheduled adding of existing issues
Query parameters:
[project_key] the project key
Query parameters:
[job_name] the name of the scheduled job
[folder_id] the folder id of the tree folder
[filter] the JQL or JIRA filter
[interval] the time interval in minutes
"""
# The REST API path to allow the creation of jobs for the scheduled adding of existing issues
path_uri = '/rest/com.easesolutions.jira.plugins.requirements/1.0/tree/' + project_key + '/createscheduledjob?'
# The field-value pair/s for the query string of the URI
job_name_field_value = 'name=' + job_name
folder_id_field_value = '&folderId=' + folder_id
filter_field_value = '&filter=' + jql_or_filter
interval_field_value = '&interval=' + interval
# The query string to be added to the URI
query_string = job_name_field_value + folder_id_field_value + filter_field_value + interval_field_value
# Send a POST request to allow the creation of jobs for the scheduled adding of existing issues
# Return the result of the POST request
try:
return requests.post(host_url + path_uri + query_string,
auth=HTTPBasicAuth(username, password))
except requests.exceptions.RequestException as e:
print e Main # ['SC'] the project key parameter where the scheduled adding job will be added
# ['Login UI Req'] job name parameter of the scheduled adding job
# ['302'] folder id parameter of the folder where the issues will be added
# ['summary ~ "Login_UI_req"'] the JQL parameter to use to get the issues
# ['2'] interval parameter in minutes
# Store the result of the POST request to [response]
response = create_scheduled_job(HOST_URL, USERNAME, PASSWORD, 'SC', 'Login UI Req', '302',
'summary ~ "Login_UI_req"', '2')
# Check response if scheduled job is created
if response.status_code == 201:
print response.text
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] Output Rule Login UI Req has been successfully created