How to add watcher to JIRA ticket using JIRA python API
Asked Answered
M

2

5

I am using JIRA python API to create JIRA tickets from my code. The code looks like below

from jira.client import JIRA
def create_jira_issue(jira, summary, description, status):

    project = getattr(settings,'jira_project_' + status)
    now = datetime.datetime.now()
    pm_jira_dict = {
        'project': {'key': getattr(settings,'jira_project_' + status)},
        'summary': summary,
        'description': description,
        'issuetype': {'name': settings.jira_issuetype},
        'assignee':{'name': settings.jira_assignee},
        'timetracking':{'originalEstimate': settings.jira_timetracking},
        'duedate':now.strftime('%Y-%m-%d %H:%M:%S')
    }

    new_issue = jira.create_issue(fields=pm_jira_dict)
    return new_issue

Now I want to add a Watcher to this ticket. How can I add it here.

Thanks in advance.

Messiah answered 30/1, 2015 at 9:57 Comment(0)
B
11

Assuming that the watcher you want to add is in the variable "watcher": Add

jira.add_watcher(new_issue.id,watcher)

at the end of your code snippet.

Berky answered 23/2, 2015 at 15:15 Comment(0)
M
0

jira.add_watcher(issue, jira._get_user_id('user'))

Mcclinton answered 19/4, 2022 at 10:27 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Illustrative

© 2022 - 2024 — McMap. All rights reserved.