-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJIRA_LeaveComment_ChangeAssigneev2.py
More file actions
59 lines (44 loc) · 1.8 KB
/
JIRA_LeaveComment_ChangeAssigneev2.py
File metadata and controls
59 lines (44 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from jira import JIRA
from jira.resources import User
process_function = True
def jira_function():
jiraOptions = {'server' : ""}
email_auth = input('Enter the email associated with the JIRA account:\n')
api_token_auth = input('Enter the API token associated with the JIRA account:\n')
jira = JIRA(options=jiraOptions, basic_auth=(f"{email_auth}",f"{api_token_auth}"))
ticket_input = input('Enter the ticket number:\n')
comment_input = input('Enter the comment to place on the ticket:\n')
assignee_input = input('Enter the assignee username:\n')
singleIssue = jira.issue(f'{ticket_input}')
print('{}: {}:{}'.format(singleIssue.key,
singleIssue.fields.summary,
singleIssue.fields.reporter.displayName))
comment_send = jira.add_comment(ticket_input,f"{comment_input}")
#Change Assignee
jira_connection = JIRA (
basic_auth=(f'{email_auth}', f'{api_token_auth}'),
server=''
)
issue = singleIssue
params = {
"query": f"{assignee_input}",
"includeActive": True,
"includeInactive": False,
}
list_search = jira_connection._fetch_pages(
User, None, "user/search", params=params
)
jira_user_id = list_search[0].accountId
fields = {"assignee": {"accountId": jira_user_id}}
issue.update(assignee=fields["assignee"])
jira_function_input = input('Enter "Y" to begin the jira function process\nEnter "N" to exit:\n')
if jira_function_input == 'Y':
jira_function()
process_cont = input('Does the process need to be continued?\nEnter "Y" or "N":\n')
if process_cont == 'Y':
jira_function()
else:
print('Exiting the program...')
if jira_function_input == 'N':
process_function = False
print('Exiting the program:')